Skip to main content

Cache

Trait Cache 

Source
pub trait Cache: Send + Sync {
Show 14 methods // Required methods fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Entry>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn put<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: Vec<u8>, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Version>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn compare_exchange<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, expected: Option<Version>, replacement: Option<Replacement>, ) -> Pin<Box<dyn Future<Output = Result<CasOutcome>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn counter<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Counter>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn increment<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, amount: u64, limit: u64, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<IncrementOutcome>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn decrement<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, generation: Version, amount: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<Counter>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn acquire_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, limit: u32, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn renew_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, owner: Version, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn release_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, owner: Version, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn publish<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Subscription>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn get_many<'life0, 'life1, 'async_trait>( &'life0 self, keys: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Entry>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn acquire_lease<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Each method is atomic for its one key. There are no cross-key transactions. KV values, counters, permits and notification topics have separate domains.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Entry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn put<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: Vec<u8>, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Version>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn compare_exchange<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, expected: Option<Version>, replacement: Option<Replacement>, ) -> Pin<Box<dyn Future<Output = Result<CasOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

None expects absence, including expiry. None replacement deletes.

Source

fn counter<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Counter>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn increment<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, amount: u64, limit: u64, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<IncrementOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn decrement<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, generation: Version, amount: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<Counter>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generation check prevents a late decrement touching a new window. This is not an idempotent receipt: the caller must release each charge once and must not blindly retry after an ambiguous transport failure.

Source

fn acquire_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, limit: u32, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Expiring concurrency permit. Use limit=1 for a refresh lease. All callers for a resource must use the same limit. No automatic renewal is performed.

Source

fn renew_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, owner: Version, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn release_permit<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, owner: Version, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn publish<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Subscription>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns after registration. Initial ResyncRequired ensures changes before registration are recovered by an authoritative reload.

Provided Methods§

Source

fn get_many<'life0, 'life1, 'async_trait>( &'life0 self, keys: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Entry>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get for each key, answered in the order asked. Each key is read atomically on its own, exactly as get reads it; the batch is not a snapshot across keys. It exists so a caller that needs many keys at once pays one lock, round trip or query instead of one per key.

Source

fn acquire_lease<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<Version>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§