pub struct FileSystemCache { /* private fields */ }Expand description
File system based cache
Stores cached values as files on disk. Each cache key maps to a file, with a companion metadata file tracking expiration.
§Directory Structure
cache_dir/
├── rekor_public_key.cache
├── rekor_public_key.meta
├── fulcio_trust_bundle.cache
├── fulcio_trust_bundle.meta
└── ...§Example
use sigstore_cache::{FileSystemCache, CacheAdapter, CacheKey};
use std::time::Duration;
// Use default location
let cache = FileSystemCache::default_location()?;
// Or specify custom directory
let cache = FileSystemCache::new("/tmp/my-sigstore-cache")?;
// Cache a value
cache.set(
CacheKey::RekorPublicKey,
b"public-key-data",
Duration::from_secs(86400)
).await?;Implementations§
Source§impl FileSystemCache
impl FileSystemCache
Sourcepub fn new(cache_dir: impl AsRef<Path>) -> Result<Self>
pub fn new(cache_dir: impl AsRef<Path>) -> Result<Self>
Create a new file system cache at the specified directory
The directory will be created if it doesn’t exist when writing.
Sourcepub fn default_location() -> Result<Self>
pub fn default_location() -> Result<Self>
Create a cache at the default platform-specific location
See default_cache_dir for the exact locations.
Warning: This cache is not namespaced by instance URL. If you use
multiple Sigstore instances (e.g., production and staging), use
FileSystemCache::for_instance instead to avoid cache collisions.
Sourcepub fn for_instance(base_url: &str) -> Result<Self>
pub fn for_instance(base_url: &str) -> Result<Self>
Create a cache namespaced to a specific Sigstore instance URL
This creates a subdirectory based on the URL, preventing cache collisions when using multiple Sigstore instances (e.g., production vs staging).
§Example
use sigstore_cache::FileSystemCache;
// Cache for production instance
let prod_cache = FileSystemCache::for_instance("https://sigstore.dev")?;
// Cache for staging instance (separate directory)
let staging_cache = FileSystemCache::for_instance("https://sigstage.dev")?;Sourcepub fn production() -> Result<Self>
pub fn production() -> Result<Self>
Create a cache for the Sigstore production instance
Equivalent to FileSystemCache::for_instance("https://sigstore.dev").
Trait Implementations§
Source§impl CacheAdapter for FileSystemCache
impl CacheAdapter for FileSystemCache
Source§impl Clone for FileSystemCache
impl Clone for FileSystemCache
Source§fn clone(&self) -> FileSystemCache
fn clone(&self) -> FileSystemCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more