pub struct PostgresBackend<K = String, V = String, C = StringCodec> { /* private fields */ }Expand description
A PostgreSQL-backed cache adapter.
Implementations§
Source§impl<K, V> PostgresBackend<K, V>
impl<K, V> PostgresBackend<K, V>
Source§impl<K, V, C> PostgresBackend<K, V, C>
impl<K, V, C> PostgresBackend<K, V, C>
Sourcepub fn with_codec<D>(self, codec: D) -> PostgresBackend<K, V, D>where
D: PostgresCodec<K, V>,
pub fn with_codec<D>(self, codec: D) -> PostgresBackend<K, V, D>where
D: PostgresCodec<K, V>,
Replaces the key/value codec.
Sourcepub fn with_table(self, table: &str) -> KapeResult<Self>
pub fn with_table(self, table: &str) -> KapeResult<Self>
Selects a validated table or schema.table identifier.
§Errors
Returns an error for unsafe or unsupported identifiers.
Source§impl<K, V, C> PostgresBackend<K, V, C>where
C: PostgresCodec<K, V>,
impl<K, V, C> PostgresBackend<K, V, C>where
C: PostgresCodec<K, V>,
Sourcepub async fn purge_expired(&self) -> KapeResult<u64>
pub async fn purge_expired(&self) -> KapeResult<u64>
Deletes expired rows owned by this namespace.
The application remains responsible for scheduling this operation and for table-wide maintenance.
§Errors
Returns a backend error when PostgreSQL rejects the operation.
Trait Implementations§
Source§impl<K, V, C> CacheBackend<K, V> for PostgresBackend<K, V, C>
impl<K, V, C> CacheBackend<K, V> for PostgresBackend<K, V, C>
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<Option<CacheEntry<V>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<Option<CacheEntry<V>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Queries one key.
Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
value: Arc<V>,
ttl: i64,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
value: Arc<V>,
ttl: i64,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stores or immediately invalidates one key using a millisecond TTL.
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Removes one key.
Source§fn get_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = KapeResult<Vec<Option<CacheEntry<V>>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = KapeResult<Vec<Option<CacheEntry<V>>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Queries multiple keys while preserving input order and duplicates.
Source§fn set_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
items: &'life1 [SetItem<&'life2 K, V>],
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>
fn set_many<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, items: &'life1 [SetItem<&'life2 K, V>], ) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>
Writes multiple uniquely keyed items in input order.
Source§fn remove_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Removes multiple keys in input order.
Auto Trait Implementations§
impl<K = String, V = String, C = StringCodec> !RefUnwindSafe for PostgresBackend<K, V, C>
impl<K = String, V = String, C = StringCodec> !UnwindSafe for PostgresBackend<K, V, C>
impl<K, V, C> Freeze for PostgresBackend<K, V, C>
impl<K, V, C> Send for PostgresBackend<K, V, C>
impl<K, V, C> Sync for PostgresBackend<K, V, C>
impl<K, V, C> Unpin for PostgresBackend<K, V, C>
impl<K, V, C> UnsafeUnpin for PostgresBackend<K, V, C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more