Class Cache
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
An LRU or HyperClock block/row cache.
Maps to rocksdb_cache_t.
public sealed class Cache : RocksDbHandle, IDisposable
- Inheritance
-
Cache
- Implements
- Inherited Members
Properties
Capacity
Gets or sets the cache capacity in bytes.
public ulong Capacity { get; set; }
Property Value
OccupancyCount
How many entries the cache currently holds.
public ulong OccupancyCount { get; }
Property Value
Remarks
Together with Usage this gives the average entry size, which is what EstimatedEntryCharge wants. Measuring it on a running database beats guessing.
PinnedUsage
Current pinned memory usage of the cache in bytes.
public ulong PinnedUsage { get; }
Property Value
TableAddressCount
How many slots the cache's hash table has.
public ulong TableAddressCount { get; }
Property Value
Remarks
Compare against OccupancyCount to see how full the table is. Chiefly of interest for a HyperClock cache, whose table is fixed at creation.
Usage
Current memory usage of the cache in bytes.
public ulong Usage { get; }
Property Value
Methods
CreateHyperClock(HyperClockCacheOptions)
Creates a HyperClock cache from options.
public static Cache CreateHyperClock(HyperClockCacheOptions options)
Parameters
optionsHyperClockCacheOptions
Returns
Remarks
Use this when the shard count matters. RocksDb copies the options, so they may be disposed straight afterwards.
CreateHyperClock(ulong, ulong)
Creates a HyperClock cache.
public static Cache CreateHyperClock(ulong capacityBytes, ulong estimatedEntryChargeBytes)
Parameters
capacityBytesulongTotal capacity in bytes.
estimatedEntryChargeBytesulongRough average entry size, or zero to let RocksDb adapt.
Returns
Remarks
HyperClock replaces the LRU cache's per-shard locking with a fixed-size table, which scales better under concurrent readers. In exchange it wants an estimate of the average entry size to size that table; passing zero lets RocksDb work it out.
CreateLru(LruCacheOptions)
Creates an LRU cache from options.
public static Cache CreateLru(LruCacheOptions options)
Parameters
optionsLruCacheOptions
Returns
Remarks
Use this when the shard count matters. RocksDb copies the options, so they may be disposed straight afterwards.
CreateLru(ulong)
Creates an LRU cache with the specified capacity (bytes).
public static Cache CreateLru(ulong capacityBytes)
Parameters
capacityBytesulong
Returns
CreateLruWithStrictCapacityLimit(ulong)
Creates an LRU cache that enforces strict capacity limits.
public static Cache CreateLruWithStrictCapacityLimit(ulong capacityBytes)
Parameters
capacityBytesulong
Returns
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().