Struct cornerstore::CornerStore[][src]

pub struct CornerStore(_);

A thread-safe store for perishable items.

Keys and values are untyped byte-streams of arbitrary length

Implementations

impl CornerStore[src]

pub fn new() -> Self[src]

pub fn with_capacity(cap: usize) -> Self[src]

pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Box<dyn Error>>[src]

Get an item, but only if it has not expired

pub fn get_key_value(
    &self,
    key: &[u8]
) -> Result<Option<(Vec<u8>, Vec<u8>)>, Box<dyn Error>>
[src]

Retrieve a key/value paid, but only if they have not expired

pub fn get_unchecked(
    &self,
    key: &[u8]
) -> Result<Option<Vec<u8>>, Box<dyn Error>>
[src]

Retrieve a value, even if it is stale

pub fn get_key_value_unchecked(
    &self,
    key: &[u8]
) -> Result<Option<(Vec<u8>, Vec<u8>)>, Box<dyn Error>>
[src]

Retrieve a key/value pair, even if the pair is stale.

pub fn set(
    &mut self,
    key: &[u8],
    val: &[u8],
    expiry: Option<Instant>
) -> Result<(), Box<dyn Error>>
[src]

Sets key to value, overwriting any previous value. Providing an optional expiry time treats the key/value pair as perishable.

pub fn update(
    &mut self,
    key: &[u8],
    val: &[u8],
    expiry: Option<Instant>
) -> Result<(), Box<dyn Error>>
[src]

pub fn remove(&mut self, key: &[u8]) -> Result<(), Box<dyn Error>>[src]

Removes the key/value pair from the store.

pub fn evict(&mut self) -> Result<(), Box<dyn Error>>[src]

Remove any expired perishable items from the store

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.