mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 01:32:55 -07:00
fix the cacher by adding locking + extra logging in the plex checker + use a const key for scheduler caching time
This commit is contained in:
parent
9c61f909de
commit
121465210d
6 changed files with 29 additions and 11 deletions
|
@ -73,8 +73,8 @@ namespace PlexRequests.Helpers
|
|||
/// <returns></returns>
|
||||
public T Get<T>(string key) where T : class
|
||||
{
|
||||
var item = Cache.Get(key) as T;
|
||||
return item;
|
||||
lock (key)
|
||||
return Cache.Get(key) as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -86,7 +86,11 @@ namespace PlexRequests.Helpers
|
|||
public void Set(string key, object data, int cacheTime = 20)
|
||||
{
|
||||
var policy = new CacheItemPolicy { AbsoluteExpiration = DateTime.Now + TimeSpan.FromMinutes(cacheTime) };
|
||||
Cache.Add(new CacheItem(key, data), policy);
|
||||
lock (key)
|
||||
{
|
||||
Cache.Remove(key);
|
||||
Cache.Add(new CacheItem(key, data), policy);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -98,7 +102,10 @@ namespace PlexRequests.Helpers
|
|||
var keys = Cache.Where(x => x.Key.Contains(key));
|
||||
foreach (var k in keys)
|
||||
{
|
||||
Cache.Remove(k.Key);
|
||||
lock (key)
|
||||
{
|
||||
Cache.Remove(k.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue