pub struct Cache(/* private fields */);Implementations§
Source§impl Cache
impl Cache
Sourcepub fn new_lru_cache(capacity: size_t) -> Cache
pub fn new_lru_cache(capacity: size_t) -> Cache
Creates an LRU cache with capacity in bytes.
Sourcepub fn new_lru_cache_opts(opts: &LruCacheOptions) -> Cache
pub fn new_lru_cache_opts(opts: &LruCacheOptions) -> Cache
Creates an LRU cache with custom options.
Sourcepub fn new_hyper_clock_cache(
capacity: size_t,
estimated_entry_charge: size_t,
) -> Cache
pub fn new_hyper_clock_cache( capacity: size_t, estimated_entry_charge: size_t, ) -> Cache
Creates a HyperClockCache with capacity in bytes.
HyperClockCache is now generally recommended over LRUCache. See RocksDB’s HyperClockCacheOptions in cache.h for details.
estimated_entry_charge is an optional parameter. When not provided
(== 0, recommended and default), an HCC variant with a
dynamically-growing table and generally good performance is used. This
variant depends on anonymous mmaps so might not be available on all
platforms.
If the average “charge” (uncompressed block size) of block cache entries
is reasonably predicted and provided here, the most efficient variant of
HCC is used. Performance is degraded if the prediction is inaccurate.
Prediction could be difficult or impossible with cache-charging features
such as WriteBufferManager. The best parameter choice based on a cache
in use is roughly given by cache.get_usage() / cache.get_occupancy_count(),
though it is better to estimate toward the lower side than the higher
side when the ratio might vary.
Sourcepub fn get_pinned_usage(&self) -> usize
pub fn get_pinned_usage(&self) -> usize
Returns the pinned memory usage in bytes.
Sourcepub fn set_capacity(&mut self, capacity: size_t)
pub fn set_capacity(&mut self, capacity: size_t)
Sets cache capacity in bytes.