Crate stretto

Crate stretto 

Source
Expand description

Stretto is a pure Rust implementation for https://github.com/dgraph-io/ristretto.

A high performance thread-safe memory-bound Rust cache.

Structs§

AsyncCacheasync
AsyncCache is a thread-safe async implementation of a hashmap with a TinyLFU admission policy and a Sampled LFU eviction policy. You can use the same AsyncCache instance from as many threads as you want.
AsyncCacheBuilderasync
The AsyncCacheBuilder struct is used when creating AsyncCache instances if you want to customize the AsyncCache settings.
Cachesync
Cache is a thread-safe implementation of a hashmap with a TinyLFU admission policy and a Sampled LFU eviction policy. You can use the same Cache instance from as many threads as you want.
CacheBuildersync
The CacheBuilder struct is used when creating Cache instances if you want to customize the Cache settings.
DefaultKeyBuilder
DefaultKeyBuilder is a built-in KeyBuilder for the Cache.
Histogram
Histogram stores the information needed to represent the sizes of the keys and values as a histogram.
Item
Item is the parameter when Cache reject, evict value,
TransparentHasher
Dummy hasher will do nothing. Used by TransparentKeyBuilder.
TransparentKeyBuilder
TransparentKeyBuilder converts key to u64. If the key does not implement the trait TransparentKey, please use DefaultKeyBuilder or write a custom key builder.
ValueRef
ValueRef is returned when invoking get method of the Cache. It contains a RwLockReadGuard and a value reference.
ValueRefMut
ValueRefMut is returned when invoking get_mut method of the Cache. It contains a RwLockWriteGuard and a mutable value reference.

Enums§

CacheError
CacheError contains the error of this crate
MetricType
The data field in a Metrics
Metrics
Metrics is a snapshot of performance statistics for the lifetime of a cache instance.

Traits§

CacheCallback
CacheCallback is for customize some extra operations on values when related event happens.
Coster
Cost is a trait you can pass to the CacheBuilder in order to evaluate item cost at runtime, and only for the insert calls that aren’t dropped (this is useful if calculating item cost is particularly expensive, and you don’t want to waste time on items that will be dropped anyways).
KeyBuilder
KeyBuilder is the hashing algorithm used for every key. In Stretto, the Cache will never store the real key. The key will be processed by KeyBuilder. Stretto has two default built-in key builder, one is TransparentKeyBuilder, the other is DefaultKeyBuilder. If your key implements TransparentKey trait, you can use TransparentKeyBuilder which is faster than DefaultKeyBuilder. Otherwise, you should use DefaultKeyBuilder You can also write your own key builder for the Cache, by implementing KeyBuilder trait.
TransparentKey
Implement this trait for the key, if you want to use TransparentKeyBuilder as the KeyBuilder for the Cache.
UpdateValidator
By default, the Cache will always update the value if the value already exists in the cache, this trait is for you to check if the value should be updated.