mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-13 01:56: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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = await factory();
|
||||||
|
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(string key)
|
public void Remove(string key)
|
||||||
|
@ -47,34 +44,34 @@ namespace Ombi.Helpers
|
||||||
_memoryCache.Remove(key);
|
_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
|
return result;
|
||||||
if (_memoryCache.TryGetValue<T>(cacheKey, out var result))
|
}
|
||||||
|
|
||||||
|
lock (TypeLock<T>.Lock)
|
||||||
|
{
|
||||||
|
if (_memoryCache.TryGetValue(cacheKey, out result))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (TypeLock<T>.Lock)
|
result = factory();
|
||||||
{
|
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
||||||
if (_memoryCache.TryGetValue(cacheKey, out result))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = factory();
|
return result;
|
||||||
_memoryCache.Set(cacheKey, result, absoluteExpiration);
|
|
||||||
|
|
||||||
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;
|
_plexRepo = plexRepo;
|
||||||
_embyRepo = embyRepo;
|
_embyRepo = embyRepo;
|
||||||
_embyContentSync = embySync;
|
_embyContentSync = embySync;
|
||||||
|
_settings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ISettingsService<PlexSettings> _settings;
|
private readonly ISettingsService<PlexSettings> _settings;
|
||||||
|
|
|
@ -57,6 +57,10 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
_ombiSettings = ombiSettings;
|
_ombiSettings = ombiSettings;
|
||||||
_plexSettings = plexSettings;
|
_plexSettings = plexSettings;
|
||||||
_embySettings = embySettings;
|
_embySettings = embySettings;
|
||||||
|
_ombiSettings.ClearCache();
|
||||||
|
_plexSettings.ClearCache();
|
||||||
|
_emailSettings.ClearCache();
|
||||||
|
_customizationSettings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IPlexContentRepository _plex;
|
private readonly IPlexContentRepository _plex;
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
EpisodeSync = epsiodeSync;
|
EpisodeSync = epsiodeSync;
|
||||||
Metadata = metadataRefresh;
|
Metadata = metadataRefresh;
|
||||||
Checker = checker;
|
Checker = checker;
|
||||||
|
Plex.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISettingsService<PlexSettings> Plex { get; }
|
private ISettingsService<PlexSettings> Plex { get; }
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
_api = plexApi;
|
_api = plexApi;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_availabilityChecker = a;
|
_availabilityChecker = a;
|
||||||
|
_settings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ISettingsService<PlexSettings> _settings;
|
private readonly ISettingsService<PlexSettings> _settings;
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
_log = log;
|
_log = log;
|
||||||
_plexSettings = plexSettings;
|
_plexSettings = plexSettings;
|
||||||
_userManagementSettings = ums;
|
_userManagementSettings = ums;
|
||||||
|
_plexSettings.ClearCache();
|
||||||
|
_userManagementSettings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IPlexApi _api;
|
private readonly IPlexApi _api;
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
||||||
RadarrApi = radarrApi;
|
RadarrApi = radarrApi;
|
||||||
Logger = log;
|
Logger = log;
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
RadarrSettings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
||||||
_api = api;
|
_api = api;
|
||||||
_log = l;
|
_log = l;
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
_settings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ISettingsService<SickRageSettings> _settings;
|
private readonly ISettingsService<SickRageSettings> _settings;
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
_api = api;
|
_api = api;
|
||||||
_log = l;
|
_log = l;
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
_settings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ISettingsService<SonarrSettings> _settings;
|
private readonly ISettingsService<SonarrSettings> _settings;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue