How to implement cache for ClientStore in IdSrv4? I'm already checking the docs at AddClientStoreCache but it does not help me... On my ConfigureServices method i'm configuring IdSrv as follows:
services.AddIdentityServer(options =>
{
options.IssuerUri = "http://idp.address.jus.br/";
options.Caching.ClientStoreExpiration = TimeSpan.FromHours(1);
})
.AddSigningCredential(cert)
.AddClientStoreCache<ClientStore>();
...And in my ClientStore implementation i do not have anything about caching...Should i check wheter the info is on cache in FindClientByIdAsync in some way? Or its done for me under the hood?
I found a sample only at IdentityServer4.Postgresql, but i can't replicate it with sucess on my custom Store classes...
If you're looking for a sample implementation of the CachingClientStore.cs
, you could check out the default implementation (the way the identity server does this) here.
public async Task<Client> FindClientByIdAsync(string clientId)
{
var client = await _cache.GetAsync(clientId,
_options.Caching.ClientStoreExpiration,
() => _inner.FindClientByIdAsync(clientId),
_logger);
return client;
}
They are giving you the choice how to implement your caching algorithm. You could cache the ClientStore in a In-Memory database such as Redis. The good thing about IdentityServer4 is you can implement the interfaces however you want and however you need them.
AddConfigurationStoreCache()
via https://github.com/IdentityServer/IdentityServer4/blob/master/src/EntityFramework/host/Startup.cs#L47
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With