pub enum PutResult<K, V> {
Put,
Update(V),
Evicted {
key: K,
value: V,
},
EvictedAndUpdate {
evicted: (K, V),
update: V,
},
}Expand description
PutResult is returned when try to put a entry in cache.
-
PutResult::Putmeans that the key is not in cache previously, and the cache has enough capacity, no evict happens. -
PutResult::Updatemeans that the key already exists in the cache, and this operation updates the key’s value and the inner is the old value. -
PutResult::Evictedmeans that the the key is not in cache previously, but the cache is full, so the evict happens. The inner is the evicted entry(Key, Value). -
PutResult::EvictedAndUpdateis only possible to be returned byTwoQueueCacheandAdaptiveCache. For more information, please see the related examples ofTwoQueueCacheandAdaptiveCache
Variants§
Put
Put means that the key is not in cache previously, and the cache has enough
capacity, no evict happens.
Update(V)
Update means that the key already exists in the cache,
and this operation updates the key’s value and the inner is the old value
Evicted
Evicted means that the the key is not in cache previously,
but the cache is full, so the evict happens. The inner is the evicted entry (Key, Value).
EvictedAndUpdate
EvictedAndUpdate is only possible to be returned by TwoQueueCache.
For more information, please see the related examples of TwoQueueCache.