pub struct InMemoryCache { /* private fields */ }Expand description
In-memory cache with TTL support
This cache stores values in memory with automatic expiration. It’s fast but not persistent across process restarts.
Thread-safe and suitable for use across async tasks.
§Example
use sigstore_cache::{InMemoryCache, CacheAdapter, CacheKey};
use std::time::Duration;
let cache = InMemoryCache::new();
// Cache a value for 1 hour
cache.set(
CacheKey::RekorPublicKey,
b"public-key-data",
Duration::from_secs(3600)
).await?;
// Retrieve it
if let Some(data) = cache.get(CacheKey::RekorPublicKey).await? {
println!("Got {} bytes", data.len());
}Implementations§
Source§impl InMemoryCache
impl InMemoryCache
Sourcepub async fn cleanup_expired(&self)
pub async fn cleanup_expired(&self)
Remove expired entries from the cache
This is called automatically on get operations, but can be
called manually to proactively clean up memory.
Trait Implementations§
Source§impl CacheAdapter for InMemoryCache
impl CacheAdapter for InMemoryCache
Source§impl Clone for InMemoryCache
impl Clone for InMemoryCache
Source§fn clone(&self) -> InMemoryCache
fn clone(&self) -> InMemoryCache
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 InMemoryCache
impl Debug for InMemoryCache
Auto Trait Implementations§
impl Freeze for InMemoryCache
impl !RefUnwindSafe for InMemoryCache
impl Send for InMemoryCache
impl Sync for InMemoryCache
impl Unpin for InMemoryCache
impl UnsafeUnpin for InMemoryCache
impl !UnwindSafe for InMemoryCache
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