Struct buildsrs_storage::Cache
source · pub struct Cache { /* private fields */ }
Expand description
Storage caching layer.
This is a layer you can use to wrap an existing storage provider to add an in-memory cache. This allows you to serve commonly requested artifacts more efficiently.
The cache is implemented using the moka crate, which is optimized for highly concurrent, lock-free access.
Implementations§
source§impl Cache
impl Cache
sourcepub fn new(storage: AnyStorage, config: CacheConfig) -> Self
pub fn new(storage: AnyStorage, config: CacheConfig) -> Self
Create new caching layer on top of a storage.
You need to create a CacheConfig
to create the cache, which specifies some important
metrics such as the capacity of the cache.
You can use CacheConfig::default()
to use defaults, which should be sane. Read the
documentation on CacheConfig
for more information on what can be tuned.
sourcepub fn storage(&self) -> &AnyStorage
pub fn storage(&self) -> &AnyStorage
Get a reference to the underlying storage.
Trait Implementations§
source§impl Storage for Cache
impl Storage for Cache
source§fn artifact_put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
version: &'life1 ArtifactId,
data: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn artifact_put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
version: &'life1 ArtifactId,
data: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Put an artifact into storage.
source§fn artifact_get<'life0, 'life1, 'async_trait>(
&'life0 self,
version: &'life1 ArtifactId
) -> Pin<Box<dyn Future<Output = Result<ArtifactData, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn artifact_get<'life0, 'life1, 'async_trait>(
&'life0 self,
version: &'life1 ArtifactId
) -> Pin<Box<dyn Future<Output = Result<ArtifactData, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an artifact from storage.
Auto Trait Implementations§
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl !UnwindSafe for Cache
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Creates a shared type from an unshared type.