Refactored cache ttl handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using PostFundManagement.Application.Abstractions;
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Services.Shared;
|
||||
using PostFundManagement.Domain;
|
||||
@@ -6,7 +6,7 @@ using PostFundManagement.Domain.Models;
|
||||
|
||||
namespace PostFundManagement.Application.Services.Users;
|
||||
|
||||
public sealed class UserCacheService(UserService service, IDistributedCache cache) : IUserService
|
||||
public sealed class UserCacheService(UserService service, IDistributedCache cache) : ServiceCacheBase, IUserService
|
||||
{
|
||||
public async ValueTask<Result<User>> GetUserAsync(Guid userId, CancellationToken cancellationToken) =>
|
||||
await Result.Try((Func<ValueTask<Result<User>>>)(async () =>
|
||||
@@ -21,7 +21,7 @@ public sealed class UserCacheService(UserService service, IDistributedCache cach
|
||||
|
||||
if (userResult.IsFailed) return userResult;
|
||||
|
||||
await cache.SetStringAsync(cacheKey, JsonSerializer.Serialize(userResult.Value));
|
||||
await cache.SetStringAsync(cacheKey, JsonSerializer.Serialize(userResult.Value), cacheOptions, cancellationToken);
|
||||
|
||||
return userResult;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public sealed class UserCacheService(UserService service, IDistributedCache cach
|
||||
|
||||
if (usersResult.IsFailed) return usersResult;
|
||||
|
||||
await cache.SetStringAsync(cacheKey, JsonSerializer.Serialize(usersResult.Value));
|
||||
await cache.SetStringAsync(cacheKey, JsonSerializer.Serialize(usersResult.Value), cacheOptions, cancellationToken);
|
||||
|
||||
return usersResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user