SecretCache

Struct SecretCache 

Source
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

Source

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
Source

pub async fn get(&self, key: &str) -> Option<SecretValue>

Gets a secret from the cache if it exists and hasn’t expired.

§Arguments
  • key - The secret name/key
§Returns

Returns Some(SecretValue) if the secret is in cache and not expired, otherwise returns None.

Source

pub async fn set(&self, key: String, value: SecretValue)

Stores a secret in the cache.

§Arguments
  • key - The secret name/key
  • value - The secret value to cache
Source

pub async fn invalidate(&self, key: &str)

Invalidates a specific secret in the cache.

§Arguments
  • key - The secret name/key to invalidate
Source

pub async fn clear(&self)

Clears all secrets from the cache.

Source

pub async fn len(&self) -> usize

Returns the number of secrets currently in the cache.

Source

pub async fn is_empty(&self) -> bool

Checks if the cache is empty.

Source

pub async fn cleanup_expired(&self)

Removes expired secrets from the cache.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.