pub struct CachedStore<S: CredentialStore> { /* private fields */ }Expand description
Caching wrapper around any CredentialStore.
Use CachedStore::new with an explicit TTL. Passing ttl = Duration::from_secs(0)
disables caching and makes every get() hit the inner store directly — the wrapper
simply proxies in that case.
Implementations§
Source§impl<S: CredentialStore> CachedStore<S>
impl<S: CredentialStore> CachedStore<S>
Sourcepub fn new(inner: S, ttl: Duration) -> Self
pub fn new(inner: S, ttl: Duration) -> Self
Wrap inner with a cache that keeps successful reads for ttl.
Cache misses (key not found) are not cached — we do not want to pin a stale negative result when credentials are rotated in behind the scenes.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Drop every cached entry (wiping their buffers). Useful for explicit logout flows.
Sourcepub fn invalidate(&self, key: &str)
pub fn invalidate(&self, key: &str)
Drop a single cached entry.
Trait Implementations§
Source§impl<S: CredentialStore> CredentialStore for CachedStore<S>
impl<S: CredentialStore> CredentialStore for CachedStore<S>
Source§fn store(&self, key: &str, value: &SecretString) -> Result<()>
fn store(&self, key: &str, value: &SecretString) -> Result<()>
Store a credential securely. Read more
Source§fn get(&self, key: &str) -> Result<Option<SecretString>>
fn get(&self, key: &str) -> Result<Option<SecretString>>
Retrieve a stored credential. Read more
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if this credential store is available and functional. Read more
Source§fn is_writable(&self) -> bool
fn is_writable(&self) -> bool
Check if this store supports write operations. Read more
Auto Trait Implementations§
impl<S> !Freeze for CachedStore<S>
impl<S> RefUnwindSafe for CachedStore<S>where
S: RefUnwindSafe,
impl<S> Send for CachedStore<S>
impl<S> Sync for CachedStore<S>
impl<S> Unpin for CachedStore<S>where
S: Unpin,
impl<S> UnsafeUnpin for CachedStore<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for CachedStore<S>where
S: UnwindSafe,
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