pub trait KeyCache {
// Required methods
fn get<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<KeySet>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set<'life0, 'async_trait>(
&'life0 self,
keyset: KeySet,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A trait for caching key sets used by CachedKeyStore.
This trait is primarily an extension point for library integrators who need a
custom cache backend (in-memory, KV store, persistent storage, etc.). Most users
should use CachedKeyStore with a provided cache implementation, such as
MokaKeyCache.
CachedKeyStore does not coordinate concurrent refreshes. Cache backends used in
concurrent contexts should provide their own internal synchronization and atomicity
guarantees for get/set/clear operations.
The cache stores the entire KeySet as a single unit, which matches how JWKS
endpoints work (they always return the full set). This avoids the N+1 fetch problem
that per-key caching would cause.
Required Methods§
Sourcefn get<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<KeySet>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<KeySet>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the cached key set.
Returns None if the cache is empty or has expired.
Implementors§
impl KeyCache for MokaKeyCache
moka and non-WebAssembly only.