pub struct InMemoryKeyCache { /* private fields */ }Available on crate feature
cache-inmemory only.Expand description
An in-memory key cache with TTL-based expiration.
Keys are stored in memory and automatically expire after the configured TTL. This implementation is thread-safe and can be shared across tasks.
§Examples
ⓘ
use jwk_simple::InMemoryKeyCache;
use std::time::Duration;
// Create a cache with 5-minute TTL
let cache = InMemoryKeyCache::new(Duration::from_secs(300));
// Or use the default TTL
let cache = InMemoryKeyCache::default();Implementations§
Source§impl InMemoryKeyCache
impl InMemoryKeyCache
Sourcepub fn with_default_ttl() -> Self
pub fn with_default_ttl() -> Self
Creates a new in-memory cache with the default TTL (5 minutes).
Trait Implementations§
Source§impl Debug for InMemoryKeyCache
impl Debug for InMemoryKeyCache
Source§impl Default for InMemoryKeyCache
impl Default for InMemoryKeyCache
Source§impl KeyCache for InMemoryKeyCache
impl KeyCache for InMemoryKeyCache
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Key>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Key>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets a key from the cache by its ID. Read more
Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
key: Key,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
key: Key,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stores a key in the cache. Read more
Auto Trait Implementations§
impl !Freeze for InMemoryKeyCache
impl !RefUnwindSafe for InMemoryKeyCache
impl Send for InMemoryKeyCache
impl Sync for InMemoryKeyCache
impl Unpin for InMemoryKeyCache
impl UnwindSafe for InMemoryKeyCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more