pub struct Entry<K, V> { /* private fields */ }
Expand description
A snapshot of a single entry in the cache.
Entry
is constructed from the methods like or_insert
on the struct returned
by cache’s entry
or entry_by_ref
methods. Entry
holds the cached key and
value at the time it was constructed. It also carries extra information about the
entry; is_fresh
method returns true
if the value was not
cached and was freshly computed.
See the followings for more information about entry
and entry_by_ref
methods:
sync::Cache
:future::Cache
:
Implementations§
source§impl<K, V> Entry<K, V>
impl<K, V> Entry<K, V>
sourcepub fn value(&self) -> &V
pub fn value(&self) -> &V
Returns a reference to the wrapped value.
Note that the returned reference is not pointing to the original value in
the cache. Instead, it is pointing to the cloned value in this Entry
.
sourcepub fn into_value(self) -> V
pub fn into_value(self) -> V
Consumes this Entry
, returning the wrapped value.
Note that the returned value is a clone of the original value in the cache.
It was cloned when this Entry
was constructed.
sourcepub fn is_fresh(&self) -> bool
pub fn is_fresh(&self) -> bool
Returns true
if the value in this Entry
was not cached and was freshly
computed.
sourcepub fn is_old_value_replaced(&self) -> bool
pub fn is_old_value_replaced(&self) -> bool
Returns true
if an old value existed in the cache and was replaced by the
value in this Entry
.
Note that the new value can be the same as the old value. This method still
returns true
in that case.