From d38eb30e4f3e30770cd404d6723dc0693b075f40 Mon Sep 17 00:00:00 2001 From: Dion Date: Thu, 24 Oct 2024 17:15:09 +0200 Subject: [PATCH] change memory cache setter --- .../Thumbnails/ThumbnailQuery.cs | 20 ++++++++++++++++--- .../FakeMocks/FakeIThumbnailQuery.cs | 1 - 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/starsky/starsky.foundation.database/Thumbnails/ThumbnailQuery.cs b/starsky/starsky.foundation.database/Thumbnails/ThumbnailQuery.cs index a50c6ec93..c6b4c2b1e 100644 --- a/starsky/starsky.foundation.database/Thumbnails/ThumbnailQuery.cs +++ b/starsky/starsky.foundation.database/Thumbnails/ThumbnailQuery.cs @@ -146,13 +146,27 @@ public async Task UpdateAsync(ThumbnailItem item) public bool IsRunningJob() { - return _memoryCache.TryGetValue($"{nameof(ThumbnailQuery)}_IsRunningJob", - out bool isRunning) && isRunning; + if ( _memoryCache == null ) + { + _logger.LogInformation("[ThumbnailQuery] MemoryCache disabled IsRunningJob"); + return false; + } + + _memoryCache.TryGetValue($"{nameof(ThumbnailQuery)}_IsRunningJob", + out bool isRunning); + return isRunning; } public bool SetRunningJob(bool value) { - _memoryCache.Set($"{nameof(ThumbnailQuery)}_IsRunningJob", value, TimeSpan.FromMinutes(30)); + if ( _memoryCache == null ) + { + _logger.LogInformation("[ThumbnailQuery] MemoryCache disabled SetRunningJob"); + return false; + } + + _memoryCache.Set($"{nameof(ThumbnailQuery)}_IsRunningJob", + value, TimeSpan.FromDays(2)); return true; } diff --git a/starsky/starskytest/FakeMocks/FakeIThumbnailQuery.cs b/starsky/starskytest/FakeMocks/FakeIThumbnailQuery.cs index 0dc9ebe0b..74739d518 100644 --- a/starsky/starskytest/FakeMocks/FakeIThumbnailQuery.cs +++ b/starsky/starskytest/FakeMocks/FakeIThumbnailQuery.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq;