Initial implementation of voice works scanning.

This commit is contained in:
2025-09-11 00:07:49 -04:00
parent f250276a99
commit 3c0a39b324
50 changed files with 1351 additions and 88 deletions

View File

@@ -0,0 +1,32 @@
using JSMR.Application.Common.Caching;
using Microsoft.Extensions.Caching.Memory;
namespace JSMR.Infrastructure.Caching.Adapters;
public class MemoryCacheAdapter(IMemoryCache memoryCache) : ICache
{
public ValueTask<T?> GetAsync<T>(string key, CancellationToken cancellationToken = default)
{
memoryCache.TryGetValue(key, out T? value);
return ValueTask.FromResult(value);
}
public ValueTask SetAsync<T>(string key, T value, CacheEntryOptions options, CancellationToken cancellationToken = default)
{
MemoryCacheEntryOptions memoryCacheOptions = new();
if (options.AbsoluteExpirationRelativeToNow != null)
memoryCacheOptions.SetAbsoluteExpiration(options.AbsoluteExpirationRelativeToNow.Value);
if (options.AbsoluteExpiration != null)
memoryCacheOptions.SetAbsoluteExpiration(options.AbsoluteExpiration.Value);
if (options.SlidingExpiration != null)
memoryCacheOptions.SetSlidingExpiration(options.SlidingExpiration.Value);
memoryCache.Set(key, value, memoryCacheOptions);
return ValueTask.CompletedTask;
}
}