Table of Contents

Class CachingResourceStore<T>

Namespace
Fdyay.IdentityServer.Stores
Assembly
Fdyay.IdentityServer.Core.dll

Holds everything a resource store says, for a duration, in a HybridCache, and answers each lookup from it.

public sealed class CachingResourceStore<T> : IResourceStore where T : IResourceStore

Type Parameters

T
Inheritance
CachingResourceStore<T>
Implements
Inherited Members

Remarks

Duende 8.0.1's CachingResourceStore<T>, measured: one entry, the store's GetAllResourcesAsync(CancellationToken), held with an absolute expiration in the HybridCache keyed ConfigurationStoreCache; each of the four lookups filters it by name — an API resource by any of its scopes — rather than asking the store. A store that answers null is not held, and reads as no resources.

An edit to a resource or scope reaches this server within the duration, not at once. The whole catalogue is read at once, so this suits a store whose catalogue is small enough to hold, which is the store that is asked for it on every request.

Takes its duration as an argument, from AddResourceStoreCache<T>(duration), where Duende reads CachingOptions.ResourceStoreExpiration, as CachingClientStore<T> does.

Constructors

CachingResourceStore(T, HybridCache, TimeSpan)

A cache in front of inner, holding its whole catalogue for duration.

public CachingResourceStore(T inner, HybridCache cache, TimeSpan duration)

Parameters

inner T

The store whose GetAllResourcesAsync(CancellationToken) is read on a miss.

cache HybridCache

The HybridCache the catalogue is held in.

duration TimeSpan

How long the catalogue is held, from when it was read; an absolute expiration.

Exceptions

ArgumentOutOfRangeException

duration is zero or negative.

Methods

FindApiResourcesByNameAsync(IEnumerable<string>, CancellationToken)

Gets API resources by resource name.

public Task<IEnumerable<ApiResource>> FindApiResourcesByNameAsync(IEnumerable<string> apiResourceNames, CancellationToken cancellationToken = default)

Parameters

apiResourceNames IEnumerable<string>
cancellationToken CancellationToken

Returns

Task<IEnumerable<ApiResource>>

FindApiResourcesByScopeNameAsync(IEnumerable<string>, CancellationToken)

Gets API resources that claim any of the given scope names.

public Task<IEnumerable<ApiResource>> FindApiResourcesByScopeNameAsync(IEnumerable<string> scopeNames, CancellationToken cancellationToken = default)

Parameters

scopeNames IEnumerable<string>
cancellationToken CancellationToken

Returns

Task<IEnumerable<ApiResource>>

FindApiScopesByNameAsync(IEnumerable<string>, CancellationToken)

Gets API scopes by scope name.

public Task<IEnumerable<ApiScope>> FindApiScopesByNameAsync(IEnumerable<string> scopeNames, CancellationToken cancellationToken = default)

Parameters

scopeNames IEnumerable<string>
cancellationToken CancellationToken

Returns

Task<IEnumerable<ApiScope>>

FindIdentityResourcesByScopeNameAsync(IEnumerable<string>, CancellationToken)

Gets identity resources by scope name.

public Task<IEnumerable<IdentityResource>> FindIdentityResourcesByScopeNameAsync(IEnumerable<string> scopeNames, CancellationToken cancellationToken = default)

Parameters

scopeNames IEnumerable<string>
cancellationToken CancellationToken

Returns

Task<IEnumerable<IdentityResource>>

GetAllResourcesAsync(CancellationToken)

Gets all resources.

public Task<Resources> GetAllResourcesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<Resources>