pub struct SecretsCache {
inner: Arc<RwLock<HashMap<String, SecretValue>>>,
}Expand description
A thread-safe, in-memory cache for IBM IAM bearer tokens.
Tokens are automatically refreshed when they are within 5 minutes of
expiry. The cache is keyed by bucket name and shared across all Pingora
worker threads via an Arc.
Fields§
§inner: Arc<RwLock<HashMap<String, SecretValue>>>Implementations§
Source§impl SecretsCache
impl SecretsCache
Sourcepub fn insert(&self, key: String, value: String, expiration: u64)
pub fn insert(&self, key: String, value: String, expiration: u64)
Insert a token value for key that expires at the given UNIX timestamp.
Sourcepub async fn get<F, Fut>(&self, key: &str, bearer_fetcher: F) -> Option<String>
pub async fn get<F, Fut>(&self, key: &str, bearer_fetcher: F) -> Option<String>
Return a valid token for key, fetching a new one via bearer_fetcher if
the cache is empty or the stored token is near expiry.
Sourcepub fn invalidate(&self, key: &str)
pub fn invalidate(&self, key: &str)
Remove the cached token for key, forcing a fresh fetch on the next call to get.
Trait Implementations§
Source§impl Clone for SecretsCache
impl Clone for SecretsCache
Source§fn clone(&self) -> SecretsCache
fn clone(&self) -> SecretsCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecretsCache
impl Debug for SecretsCache
Auto Trait Implementations§
impl Freeze for SecretsCache
impl RefUnwindSafe for SecretsCache
impl Send for SecretsCache
impl Sync for SecretsCache
impl Unpin for SecretsCache
impl UnsafeUnpin for SecretsCache
impl UnwindSafe for SecretsCache
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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