pub trait PgCacheConn: Send + Sync {
// Required methods
fn select<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn upsert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
value: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn keys<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<u64, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
The minimal typed Postgres row-verb surface PgStorageBackend depends on.
This is the injectable Environment seam: a real implementation
([SqlxPgCacheConn], postgres feature) talks to a live Postgres pool; tests
substitute an in-memory mock. Keeping the surface this small means the whole L2
mapping is proven against a mock, and the only unmocked code is the thin
SQL translation.
Required Methods§
Sourcefn select<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn select<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
SELECT value FROM <table> WHERE key = $1 — raw bytes, or Ok(None) on a
missing row.
Sourcefn upsert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
value: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), 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,
table: PgTable,
key: &'life1 str,
value: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Upsert (INSERT … ON CONFLICT (key) DO UPDATE) — idempotent by key; a
re-put of a content-addressed key overwrites with identical bytes.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
table: PgTable,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
DELETE FROM <table> WHERE key = $1 — idempotent; deleting an absent key
is Ok(()).
Sourcefn keys<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn keys<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
SELECT key FROM <table> — the authoritative full key set (this is a
durable tier, not a partial hot cache).
Sourcefn clear<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<u64, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
table: PgTable,
) -> Pin<Box<dyn Future<Output = Result<u64, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
DELETE FROM <table> — clear the whole table, returning the row count
removed. The typed whole-store wipe primitive (the inverse of a warm
push); reaches NAR rows a per-key delete cannot.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".