Skip to content

Commit

Permalink
change memory cache setter
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Oct 24, 2024
1 parent f657488 commit d38eb30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 17 additions & 3 deletions starsky/starsky.foundation.database/Thumbnails/ThumbnailQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,27 @@ public async Task<bool> 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;
}

Expand Down
1 change: 0 additions & 1 deletion starsky/starskytest/FakeMocks/FakeIThumbnailQuery.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand Down

0 comments on commit d38eb30

Please sign in to comment.