IdentityServer's ICache<T>
interface has superfluous functionality, which makes it hard to implement.
#251
Replies: 2 comments 1 reply
-
Removing You can implement public async Task<T?> GetAsync(string key)
{
return await cache.GetOrCreateAsync(key, _ => ValueTask.FromResult(default(T?)),
new HybridCacheEntryOptions
{
Flags = HybridCacheEntryFlags.DisableLocalCacheWrite |
HybridCacheEntryFlags.DisableDistributedCacheWrite
});
} |
Beta Was this translation helpful? Give feedback.
-
We've moved to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was trying to implement MS's hybrid cache for identity server, because I have an API attached to it that manages server's configuration in an environment with a lot of distributed services. I am trying to implement resource cache invalidation upon updates to said resources, so way to do this this would be to replace IdentityServer's stock implementation of
ICache<T>
for certain resources.The best fit for this in my scenario would be to use Microsoft's Hybrid Cache because it supports cache invalidation by tags (which is desirable in my case), but the issue is that it doesn't expose
Get
by itself, onlyGetOrCreate
, which is arguably a more semantically correct way to use the cache. Looking at the sources, it doesn't seem too daunting to remove this method in favour ofGetOrCreate
.Is the
Get
method really necessary in this interface?Beta Was this translation helpful? Give feedback.
All reactions