barrel_cache (barrel_docdb v1.0.0)
View SourceShared RocksDB block cache manager
Manages a shared block cache used by all RocksDB instances. This improves memory efficiency and cache hit rates by sharing a single cache across document stores and attachment stores.
The cache is configured via application environment:
{barrel_docdb, [
{block_cache_size, 536870912}, %% 512MB default
{block_cache_type, clock} %% clock (default) or lru
]}Clock cache provides better performance under concurrent load.
Summary
Functions
Get block-based table options with shared cache and bloom filter
Get block-based table options with custom settings
Get the shared cache handle
Start the cache manager
Functions
-spec get_block_opts() -> list().
Get block-based table options with shared cache and bloom filter
Get block-based table options with custom settings
Options: - bloom_bits: Bloom filter bits per key (default: 10) - block_size: Block size in bytes (default: 4096) - cache_index_and_filter: Cache index/filter blocks (default: true)
If the cache process is not running (e.g., during standalone tests), returns options without the shared cache.
-spec get_cache() -> {ok, rocksdb:cache_handle()} | {error, not_started}.
Get the shared cache handle
Start the cache manager