fix: exception if value is null
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m53s
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m53s
This commit is contained in:
parent
8d4c482bbd
commit
612efcb91c
@ -23,8 +23,11 @@ public class MemoryCacheService(IMemoryCache cache) : ICacheService
|
|||||||
|
|
||||||
public Task<T?> GetAsync<T>(string key, CancellationToken cancellationToken = default)
|
public Task<T?> GetAsync<T>(string key, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
cache.TryGetValue(key, out byte[]? value);
|
return Task.FromResult(
|
||||||
return Task.FromResult(JsonSerializer.Deserialize<T>(value));
|
cache.TryGetValue(key, out byte[]? value) ?
|
||||||
|
JsonSerializer.Deserialize<T>(value) :
|
||||||
|
default
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task RemoveAsync(string key, CancellationToken cancellationToken = default)
|
public Task RemoveAsync(string key, CancellationToken cancellationToken = default)
|
||||||
|
Loading…
Reference in New Issue
Block a user