pub struct SecretCache { /* private fields */ }Expand description
In-memory cache for secrets with TTL.
This cache reduces the number of API calls to cloud secret managers.
Implementations§
Source§impl SecretCache
impl SecretCache
Sourcepub fn new(ttl_seconds: u64) -> Self
pub fn new(ttl_seconds: u64) -> Self
Creates a new secret cache with the specified TTL.
§Arguments
ttl_seconds- Default time-to-live for cached secrets in seconds
Sourcepub async fn get(&self, key: &str) -> Option<SecretValue>
pub async fn get(&self, key: &str) -> Option<SecretValue>
Sourcepub async fn set(&self, key: String, value: SecretValue)
pub async fn set(&self, key: String, value: SecretValue)
Stores a secret in the cache.
§Arguments
key- The secret name/keyvalue- The secret value to cache
Sourcepub async fn invalidate(&self, key: &str)
pub async fn invalidate(&self, key: &str)
Sourcepub async fn cleanup_expired(&self)
pub async fn cleanup_expired(&self)
Removes expired secrets from the cache.
Auto Trait Implementations§
impl Freeze for SecretCache
impl !RefUnwindSafe for SecretCache
impl Send for SecretCache
impl Sync for SecretCache
impl Unpin for SecretCache
impl !UnwindSafe for SecretCache
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