1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

fix memory/database leak with ranked player count cache

This commit is contained in:
RaidMax
2022-06-12 12:19:32 -05:00
parent 6d9cc9b19f
commit 2af3e61fe5
2 changed files with 3 additions and 2 deletions

View File

@ -18,6 +18,7 @@ namespace Data.Helpers
private readonly IDatabaseContextFactory _contextFactory;
private readonly ConcurrentDictionary<string, Dictionary<object, CacheState<TReturnType>>> _cacheStates = new();
private readonly object _defaultKey = new();
private bool _autoRefresh;
private const int DefaultExpireMinutes = 15;
@ -58,7 +59,7 @@ namespace Data.Helpers
public void SetCacheItem(Func<DbSet<TEntityType>, CancellationToken, Task<TReturnType>> getter, string key,
IEnumerable<object> ids = null, TimeSpan? expirationTime = null, bool autoRefresh = false)
{
ids ??= new[] { new object() };
ids ??= new[] { _defaultKey };
if (!_cacheStates.ContainsKey(key))
{