Struct concread::arcache::ARCache [−][src]
pub struct ARCache<K, V> where
K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static,
V: Clone + Debug + Sync + Send + 'static, { /* fields omitted */ }
Expand description
A concurrently readable adaptive replacement cache. Operations are performed on the cache via read and write operations.
Implementations
Create a new ARCache, that derives it’s size based on your expected workload.
The values are total number of items you want to have in memory, the number of read threads you expect concurrently, the expected average number of cache misses per read operation, and the expected average number of writes or write cache misses per operation. The following formula is assumed:
max + (threads * (max/16))
+ (threads * avg number of misses per op)
+ avg number of writes per transaction
The cache may still exceed your provided total, and inaccurate tuning numbers will yield a situation where you may use too-little ram, or too much. This could be to your read misses exceeding your expected amount causing the queues to have more items in them at a time, or your writes are larger than expected.
If you set ex_ro_miss to zero, no read thread local cache will be configured, but space will still be reserved for channel communication.
Create a new ARCache, with a capacity of max
main cache items and read_max
Note that due to the way the cache operates, the number of items can and
will exceed max
on a regular basis, so you should consider using new
and specifying your expected workload parameters to have a better derived
cache size.
See [new_size] for more information. This allows manual configuration of the data tracking watermark. To disable this, set to 0. Watermark must be less than max.
Begin a read operation on the cache. This reader has a thread-local cache for items
that are localled included via insert
, and can communicate back to the main cache
to safely include items.
Begin a write operation on the cache. This writer has a thread-local store for all items that have been included or dirtied in the transactions, items may be removed from this cache (ie deleted, invalidated).
View the statistics for this cache. These values are a snapshot of a point in time and may not be accurate at “this exact moment”.