Rust

adapter

Module

[Adapter]: where a cache keeps its entries, and the dynamic form DynAdapter for adapters chosen at run time.

Contents

use utopia_cache::Retry;
Rust
pub struct Retry

Retries of a networked adapter: how many times a command that failed on the connection is retried, and the pause between attempts.

Also implements Default.
use utopia_cache::Adapter;
Rust
pub trait Adapter: Send + Sync

A cache backend.

Entries live under a key; adapters that store hashes keep several fields under one key, chosen by hash (an empty or "0" hash means the key itself). A load misses (None) when the entry is absent or older than its ttl. Implement it to add a backend; the optional capabilities (batches of fields, leases, telemetry) have defaults that behave like an adapter without them.

use utopia_cache::DynAdapter;
Rust
pub trait DynAdapter: Send + Sync

The object-safe form of Adapter, implemented for every adapter, so adapters of different types can share a Vec<Arc<dyn DynAdapter>> (and dyn DynAdapter is itself an Adapter).

Implemented byA
Rust
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>

A boxed future, for DynAdapter.

Rust
pub type Fields = IndexMap<String, Value>

Fields of a hash and their values, in order.