[−][src]Trait fn_memo::sync::Cache
The cache for synchronized memoization.
Associated Types
Loading content...Required methods
fn new() -> Self
Creates an empty cache.
fn get(&self, arg: &Self::Arg) -> Option<Arc<OnceCell<Self::Output>>>
Gets the cell of the arg
in cache. Returns None
if arg
is not cached.
This method should only acquire read lock if needed.
fn get_or_new(&self, arg: Self::Arg) -> Arc<OnceCell<Self::Output>>
Gets the cell of the arg
in cache, creates if arg
is not cached.
This method may acquire write lock if needed.
fn clear(&self)
Clears the cache.
Implementations on Foreign Types
impl<Arg, Output> Cache for CHashMap<Arg, Arc<OnceCell<Output>>> where
Arg: Eq + Hash,
[src]
Arg: Eq + Hash,
Use CHashMap
as Cache
.
type Arg = Arg
type Output = Output
fn new() -> Self
[src]
fn get(&self, arg: &Self::Arg) -> Option<Arc<OnceCell<Self::Output>>>
[src]
fn get_or_new(&self, arg: Self::Arg) -> Arc<OnceCell<Self::Output>>
[src]
fn clear(&self)
[src]
impl<Arg, Output> Cache for RwLock<HashMap<Arg, Arc<OnceCell<Output>>>> where
Arg: Eq + Hash,
[src]
Arg: Eq + Hash,
Use HashMap
with RwLock
as Cache
.
type Arg = Arg
type Output = Output
fn new() -> Self
[src]
fn get(&self, arg: &Self::Arg) -> Option<Arc<OnceCell<Self::Output>>>
[src]
fn get_or_new(&self, arg: Self::Arg) -> Arc<OnceCell<Self::Output>>
[src]
fn clear(&self)
[src]
impl<Output> Cache for RwLock<Vec<Arc<OnceCell<Output>>>>
[src]
Use Vec
with RwLock
as Cache
for sequences.