pub struct RedbCache { /* private fields */ }Expand description
The durable/ephemeral redb-backed Cache.
Implementations§
Source§impl RedbCache
impl RedbCache
Sourcepub async fn flush(&self) -> Result<(), CacheError>
pub async fn flush(&self) -> Result<(), CacheError>
Force one fully durable (fsync’d) commit against this store, touching
no data. Inherent (not on the Cache trait) because durability is a
redb-specific, storage-engine concept, not a portable identity-store
operation — callers need a concrete RedbCache (via
Store::cache), not just impl Cache/dyn Cache.
Call this once right after the last chunk of a
BatchDurability::Eventual bulk load (see Store::open_with) —
don’t rely on the store closing naturally to persist those chunks, as
it may stay open for the rest of the process’s lifetime and a crash
any time before it closes would lose everything since the last durable
commit (see BatchDurability for the full crash-vs-clean-shutdown
distinction). redb commits are cumulative, so this one fsync persists
every prior Eventual upsert_batch commit too, not just this call.
A no-op-but-safe-to-call if this store’s bulk durability is
BatchDurability::Durable (every write already fsyncs on its own).
§Errors
CacheError::Backend if the (empty) transaction fails to commit.
Trait Implementations§
Source§impl Cache for RedbCache
impl Cache for RedbCache
Source§fn get_by_id<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_id<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_by_simbad_oid<'life0, 'async_trait>(
&'life0 self,
oid: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_simbad_oid<'life0, 'async_trait>(
&'life0 self,
oid: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_by_normalized<'life0, 'life1, 'async_trait>(
&'life0 self,
normalized: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_normalized<'life0, 'life1, 'async_trait>(
&'life0 self,
normalized: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTarget>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
limit. Local-only, no network. A blank query or limit == 0 → empty. Read moreSource§fn upsert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identity: &'life1 ResolvedIdentity,
namespace: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<(Uuid, UpsertOutcome), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn upsert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identity: &'life1 ResolvedIdentity,
namespace: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<(Uuid, UpsertOutcome), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
namespace
is the caller’s id namespace for the designation-derived fallback id. Read moreSource§fn upsert_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identities: &'life1 [ResolvedIdentity],
namespace: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, UpsertOutcome)>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn upsert_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identities: &'life1 [ResolvedIdentity],
namespace: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, UpsertOutcome)>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
namespace, in order, with the exact
same per-entry dedup + precedence semantics as calling Cache::upsert
once per identity (including UpsertOutcome::SkippedUserOverride and
dedup against earlier entries of the same batch). Read moreSource§fn add_user_alias<'life0, 'life1, 'async_trait>(
&'life0 self,
target_id: Uuid,
alias: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_user_alias<'life0, 'life1, 'async_trait>(
&'life0 self,
target_id: Uuid,
alias: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
kind = 'user'). Returns true if newly inserted,
false if it already existed (idempotent). Read moreSource§fn remove_user_alias<'life0, 'life1, 'async_trait>(
&'life0 self,
alias_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_user_alias<'life0, 'life1, 'async_trait>(
&'life0 self,
alias_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
kind = 'user'. Returns whether a
row was removed. Read more