Class LruCacheOptions
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
Settings for a least-recently-used block cache. Maps to
rocksdb_lru_cache_options_t.
public sealed class LruCacheOptions : RocksDbHandle, IDisposable
- Inheritance
-
LruCacheOptions
- Implements
- Inherited Members
Remarks
Only needed to control sharding. CreateLru(ulong) covers the common case. RocksDb copies these when the cache is created, so this object may be disposed straight afterwards.
Constructors
LruCacheOptions()
Creates options with RocksDb's defaults.
public LruCacheOptions()
Properties
Capacity
Total cache capacity in bytes. Write-only.
public ulong Capacity { set; }
Property Value
NumShardBits
Base-2 logarithm of the shard count. Negative lets RocksDb choose. Write-only.
public int NumShardBits { set; }
Property Value
Remarks
More shards reduce lock contention between threads but waste capacity, because each shard gets an equal slice and they fill unevenly. Worth raising only when cache contention is measurably the problem.
Methods
DisposeHandle()
Releases the native handle. Called during disposal.
protected override void DisposeHandle()
Remarks
Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().