Struct MemCache

Source
pub struct MemCache<K, T>
where K: Eq + Hash,
{ pub mode: MemCacheMode, pub time_out_fn: Option<Arc<dyn Fn(K, T) + Send + Sync>>, /* private fields */ }

Fields§

§mode: MemCacheMode§time_out_fn: Option<Arc<dyn Fn(K, T) + Send + Sync>>

Implementations§

Source§

impl<K, T> MemCache<K, T>
where K: Eq + Hash + Clone, T: Clone,

Source

pub fn new() -> Self

Source

pub fn new_with_clear_interval(interval_millis: u64) -> Self

Source

pub fn get_time_out_keys(&self) -> LinkedList<&K>

Source

pub fn clear_time_out(&mut self)

Source

pub fn set(&mut self, key: K, val: T, cache_sec: i32)

Source

pub fn update_time_out(&mut self, key: &K, cache_sec: i32)

Source

pub fn get(&self, key: &K) -> Result<T, String>

Source

pub fn time_to_live(&self, key: &K) -> i32

return the key value time to live; The unit of time returned is seconds

Source

pub fn remove(&mut self, key: &K) -> Option<T>

Source

pub fn len(&self) -> usize

Source

pub fn item_size(&self) -> usize

Trait Implementations§

Source§

impl<K, T: Default> Default for MemCache<K, T>
where K: Eq + Hash + Default,

Source§

fn default() -> MemCache<K, T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, T> Freeze for MemCache<K, T>

§

impl<K, T> !RefUnwindSafe for MemCache<K, T>

§

impl<K, T> Send for MemCache<K, T>
where K: Send, T: Send,

§

impl<K, T> Sync for MemCache<K, T>
where K: Sync, T: Sync,

§

impl<K, T> Unpin for MemCache<K, T>
where K: Unpin, T: Unpin,

§

impl<K, T> !UnwindSafe for MemCache<K, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.