-
Notifications
You must be signed in to change notification settings - Fork 80
Handle null cache client implementations in DarcLib #5068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
08b2a9c
7015283
9c5805b
cd68b74
24ff71e
efa43fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,12 @@ | |
namespace ProductConstructionService.Common; | ||
|
||
/// <summary> | ||
/// This class acts as a delegate for RedisCache and RedisCacheFactory. | ||
/// It is needed because DarcLib does not depend on ProductConstructionService and can only access caching through a delegate. | ||
/// This class acts as a delegate for RedisCache and RedisCacheFactory. It is needed because DarcLib | ||
/// does not depend on ProductConstructionService and can only implement caching there through a delegate. | ||
/// </summary> | ||
internal class RedisCacheClient : IRedisCacheClient | ||
internal class RedisCacheClient : IDistributedCacheClient | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adamzip I was asking in Teams but probably you missed that one - why does it need to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be persistent if possible but I suppose technically it can be a memory cache, yes. So do you propose just |
||
{ | ||
private static readonly TimeSpan DefaultExpiration = TimeSpan.FromDays(15); | ||
private readonly IRedisCacheFactory _factory; | ||
private readonly ILogger<RedisCacheClient> _logger; | ||
|
||
|
@@ -26,11 +27,11 @@ public RedisCacheClient(IRedisCacheFactory factory, ILogger<RedisCacheClient> lo | |
return await _factory.Create<T>(key).TryGetStateAsync(); | ||
} | ||
|
||
public async Task<bool> TrySetAsync<T>(string key, T value, TimeSpan? expiration = null) where T : class | ||
public async Task<bool> TrySetAsync<T>(string key, T value, TimeSpan? expiration) where T : class | ||
{ | ||
try | ||
{ | ||
await _factory.Create<T>(key).SetAsync(value, expiration); | ||
await _factory.Create<T>(key).SetAsync(value, expiration ?? DefaultExpiration); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.