pub struct JwtCache { /* private fields */ }Expand description
Thread-safe JWT cache backed by Moka.
Create one instance at application startup and share it across handlers
via Arc or axum State.
Implementations§
Source§impl JwtCache
impl JwtCache
Sourcepub fn new(max_entries: u64) -> Self
pub fn new(max_entries: u64) -> Self
Create a new cache with the given maximum number of entries.
Sourcepub async fn get(&self, token: &str) -> Option<Arc<AuthResult>>
pub async fn get(&self, token: &str) -> Option<Arc<AuthResult>>
Look up a cached validation result for the given raw token.
Sourcepub async fn insert(&self, token: &str, result: AuthResult)
pub async fn insert(&self, token: &str, result: AuthResult)
Store a validation result, deriving TTL from the exp claim.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidate all cached entries (e.g. on config reload).
Sourcepub fn entry_count(&self) -> u64
pub fn entry_count(&self) -> u64
Number of entries currently in the cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JwtCache
impl !RefUnwindSafe for JwtCache
impl Send for JwtCache
impl Sync for JwtCache
impl Unpin for JwtCache
impl UnsafeUnpin for JwtCache
impl !UnwindSafe for JwtCache
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