mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Fixed #2910
This commit is contained in:
parent
5356143d13
commit
c556334f79
9 changed files with 39 additions and 30 deletions
|
@ -28,18 +28,15 @@ namespace Ombi.Helpers
|
|||
return result;
|
||||
}
|
||||
|
||||
using (await _mutex.LockAsync())
|
||||
if (_memoryCache.TryGetValue(cacheKey, out result))
|
||||
{
|
||||
if (_memoryCache.TryGetValue(cacheKey, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await factory();
|
||||
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await factory();
|
||||
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
|
@ -47,34 +44,34 @@ namespace Ombi.Helpers
|
|||
_memoryCache.Remove(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public T GetOrAdd<T>(string cacheKey, Func<T> factory, DateTime absoluteExpiration)
|
||||
|
||||
|
||||
public T GetOrAdd<T>(string cacheKey, Func<T> factory, DateTime absoluteExpiration)
|
||||
{
|
||||
// locks get and set internally
|
||||
if (_memoryCache.TryGetValue<T>(cacheKey, out var result))
|
||||
{
|
||||
// locks get and set internally
|
||||
if (_memoryCache.TryGetValue<T>(cacheKey, out var result))
|
||||
return result;
|
||||
}
|
||||
|
||||
lock (TypeLock<T>.Lock)
|
||||
{
|
||||
if (_memoryCache.TryGetValue(cacheKey, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
lock (TypeLock<T>.Lock)
|
||||
{
|
||||
if (_memoryCache.TryGetValue(cacheKey, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = factory();
|
||||
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||
|
||||
result = factory();
|
||||
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TypeLock<T>
|
||||
{
|
||||
public static object Lock { get; } = new object();
|
||||
}
|
||||
|
||||
private static class TypeLock<T>
|
||||
{
|
||||
public static object Lock { get; } = new object();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
_plexRepo = plexRepo;
|
||||
_embyRepo = embyRepo;
|
||||
_embyContentSync = embySync;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly ISettingsService<PlexSettings> _settings;
|
||||
|
|
|
@ -57,6 +57,10 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
_ombiSettings = ombiSettings;
|
||||
_plexSettings = plexSettings;
|
||||
_embySettings = embySettings;
|
||||
_ombiSettings.ClearCache();
|
||||
_plexSettings.ClearCache();
|
||||
_emailSettings.ClearCache();
|
||||
_customizationSettings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly IPlexContentRepository _plex;
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
EpisodeSync = epsiodeSync;
|
||||
Metadata = metadataRefresh;
|
||||
Checker = checker;
|
||||
Plex.ClearCache();
|
||||
}
|
||||
|
||||
private ISettingsService<PlexSettings> Plex { get; }
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
_api = plexApi;
|
||||
_repo = repo;
|
||||
_availabilityChecker = a;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly ISettingsService<PlexSettings> _settings;
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
_log = log;
|
||||
_plexSettings = plexSettings;
|
||||
_userManagementSettings = ums;
|
||||
_plexSettings.ClearCache();
|
||||
_userManagementSettings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly IPlexApi _api;
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|||
RadarrApi = radarrApi;
|
||||
Logger = log;
|
||||
_ctx = ctx;
|
||||
RadarrSettings.ClearCache();
|
||||
}
|
||||
|
||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
|||
_api = api;
|
||||
_log = l;
|
||||
_ctx = ctx;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly ISettingsService<SickRageSettings> _settings;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
|||
_api = api;
|
||||
_log = l;
|
||||
_ctx = ctx;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly ISettingsService<SonarrSettings> _settings;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue