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§
- Async
Cache async - 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.
- Async
Cache Builder async - The
AsyncCacheBuilderstruct is used when creatingAsyncCacheinstances if you want to customize theAsyncCachesettings. - Cache
sync - 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.
- Cache
Builder sync - The
CacheBuilderstruct is used when creatingCacheinstances if you want to customize theCachesettings. - Default
KeyBuilder - DefaultKeyBuilder is a built-in
KeyBuilderfor the Cache. - Histogram
Histogramstores 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,
- Transparent
Hasher - Dummy hasher will do nothing. Used by
TransparentKeyBuilder. - Transparent
KeyBuilder - TransparentKeyBuilder converts key to
u64. If the key does not implement the traitTransparentKey, please useDefaultKeyBuilderor write a custom key builder. - Value
Ref - ValueRef is returned when invoking
getmethod of the Cache. It contains aRwLockReadGuardand a value reference. - Value
RefMut - ValueRefMut is returned when invoking
get_mutmethod of the Cache. It contains aRwLockWriteGuardand a mutable value reference.
Enums§
- Cache
Error - CacheError contains the error of this crate
- Metric
Type - The data field in a Metrics
- Metrics
- Metrics is a snapshot of performance statistics for the lifetime of a cache instance.
Traits§
- Cache
Callback - 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
insertcalls 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
KeyBuilderis the hashing algorithm used for every key. In Stretto, the Cache will never store the real key. The key will be processed byKeyBuilder. Stretto has two default built-in key builder, one isTransparentKeyBuilder, the other isDefaultKeyBuilder. If your key implementsTransparentKeytrait, you can useTransparentKeyBuilderwhich is faster thanDefaultKeyBuilder. Otherwise, you should useDefaultKeyBuilderYou can also write your own key builder for the Cache, by implementingKeyBuildertrait.- Transparent
Key - Implement this trait for the key, if you want to use
TransparentKeyBuilderas theKeyBuilderfor theCache. - Update
Validator - 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.