pub struct MemoryIdempotencyStore { /* private fields */ }Expand description
In-memory idempotency cache.
Implementations§
Source§impl MemoryIdempotencyStore
impl MemoryIdempotencyStore
pub fn new() -> Self
Sourcepub fn with_inflight_ttl(self, ttl: Duration) -> Self
pub fn with_inflight_ttl(self, ttl: Duration) -> Self
Override the TTL used for in-flight begin entries. Default 300s.
Set this to be at least as long as the slowest handler that may
register an idempotency key — anything shorter risks an in-flight
entry expiring before the handler completes, breaking coalescing.
Trait Implementations§
Source§impl Clone for MemoryIdempotencyStore
impl Clone for MemoryIdempotencyStore
Source§fn clone(&self) -> MemoryIdempotencyStore
fn clone(&self) -> MemoryIdempotencyStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for MemoryIdempotencyStore
impl Default for MemoryIdempotencyStore
Source§impl IdempotencyStore for MemoryIdempotencyStore
impl IdempotencyStore for MemoryIdempotencyStore
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<IdempotencyEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<IdempotencyEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads an existing entry for
key.Source§fn begin<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
payload_sig: [u8; 20],
) -> Pin<Box<dyn Future<Output = IdempotencyEntry> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn begin<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
payload_sig: [u8; 20],
) -> Pin<Box<dyn Future<Output = IdempotencyEntry> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Marks
key as in-flight; returns the freshly inserted record, or the
existing one if another request arrived first.Source§fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
entry: IdempotencyEntry,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
entry: IdempotencyEntry,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persists a completed entry with the configured TTL.
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Removes the entry — typically invoked when the handler decided not to
cache the result (e.g. opt-out via response header).
Auto Trait Implementations§
impl Freeze for MemoryIdempotencyStore
impl RefUnwindSafe for MemoryIdempotencyStore
impl Send for MemoryIdempotencyStore
impl Sync for MemoryIdempotencyStore
impl Unpin for MemoryIdempotencyStore
impl UnsafeUnpin for MemoryIdempotencyStore
impl UnwindSafe for MemoryIdempotencyStore
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