pub struct RedbManager { /* private fields */ }Available on crate feature
manager-redb only.Expand description
Implements CacheManager with redb
as the backend — a pure-Rust, embedded, persistent key/value store.
All operations are synchronous and require no async runtime, so this
manager works under any executor (tokio, smol, Bevy, …) and adds no
tokio dependency.
Implementations§
Source§impl RedbManager
impl RedbManager
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self>
pub fn new(path: impl AsRef<Path>) -> Result<Self>
Creates a new RedbManager, creating or opening the redb database
file at path.
Returns an error if the database cannot be opened (for example if another instance already holds the exclusive file lock).
Sourcepub fn from_database(db: Arc<Database>) -> Result<Self>
pub fn from_database(db: Arc<Database>) -> Result<Self>
Wraps an already-open redb Database, allowing callers to configure
the database (cache size, etc.) before handing it to the manager.
Sourcepub fn from_database_with_flush_interval(
db: Arc<Database>,
flush_interval: u64,
) -> Result<Self>
pub fn from_database_with_flush_interval( db: Arc<Database>, flush_interval: u64, ) -> Result<Self>
Like from_database, but flushes stores to
disk every flush_interval writes instead of the default 64. An
interval of 1 flushes after every store.
Trait Implementations§
Source§impl CacheManager for RedbManager
impl CacheManager for RedbManager
Source§async fn get(
&self,
cache_key: &str,
) -> Result<Option<(HttpResponse, CachePolicy)>>
async fn get( &self, cache_key: &str, ) -> Result<Option<(HttpResponse, CachePolicy)>>
Attempts to pull a cached response and related policy from cache.
Source§async fn put(
&self,
cache_key: String,
response: HttpResponse,
policy: CachePolicy,
) -> Result<HttpResponse>
async fn put( &self, cache_key: String, response: HttpResponse, policy: CachePolicy, ) -> Result<HttpResponse>
Attempts to cache a response and related policy.
Source§impl Clone for RedbManager
impl Clone for RedbManager
Source§fn clone(&self) -> RedbManager
fn clone(&self) -> RedbManager
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RedbManager
impl !UnwindSafe for RedbManager
impl Freeze for RedbManager
impl Send for RedbManager
impl Sync for RedbManager
impl Unpin for RedbManager
impl UnsafeUnpin for RedbManager
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