[#BloombergLP-bdlcc-Cache] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::Cache :relfileprefix: ../../ :mrdocs: This class represents a simple in‐process key‐value store supporting a variety of eviction policies. == Synopsis Declared in `<bdlcc_cache.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class KEY, class VALUE, class HASH = xref:bsl/hash-06.adoc[bsl::hash<KEY>], class EQUAL = xref:bsl/equal_to-0d.adoc[bsl::equal_to<KEY>]> class Cache; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/Cache/KVType.adoc[`KVType`] | Value type of a bulk insert entry. | xref:BloombergLP/bdlcc/Cache/PostEvictionCallback.adoc[`PostEvictionCallback`] | Type of function to call after an item has been evicted from the cache. | xref:BloombergLP/bdlcc/Cache/ValuePtrType.adoc[`ValuePtrType`] | Shared pointer type pointing to value type. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/Cache/2constructor-0a7.adoc[`Cache`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlcc/Cache/clear.adoc[`clear`] | Remove all items from this cache. Do _not_ invoke the post‐eviction callback. | xref:BloombergLP/bdlcc/Cache/equalFunction.adoc[`equalFunction`] | Return (a copy of) the key‐equality functor used by this cache that returns `true` if two `KEY` objects have the same value, and `false` otherwise. | xref:BloombergLP/bdlcc/Cache/erase.adoc[`erase`] | Remove the item having the specified `key` from this cache. | xref:BloombergLP/bdlcc/Cache/eraseBulk-0d.adoc[`eraseBulk`] | `eraseBulk` overloads | xref:BloombergLP/bdlcc/Cache/evictionPolicy.adoc[`evictionPolicy`] | Return the eviction policy used by this cache. | xref:BloombergLP/bdlcc/Cache/hashFunction.adoc[`hashFunction`] | Return (a copy of) the unary hash functor used by this cache to generate a hash value (of type `std::size_t`) for a `KEY` object. | xref:BloombergLP/bdlcc/Cache/highWatermark.adoc[`highWatermark`] | Return the high watermark of this cache, which is the size at which eviction of existing items begins. | xref:BloombergLP/bdlcc/Cache/insert-08.adoc[`insert`] | `insert` overloads | xref:BloombergLP/bdlcc/Cache/insertBulk-0d.adoc[`insertBulk`] | `insertBulk` overloads | xref:BloombergLP/bdlcc/Cache/lowWatermark.adoc[`lowWatermark`] | Return the low watermark of this cache, which is the size at which eviction of existing items ends. | xref:BloombergLP/bdlcc/Cache/popFront.adoc[`popFront`] | Remove the item at the front of the eviction queue. Invoke the post‐eviction callback for the removed item. Return 0 on success, and 1 if this cache is empty. | xref:BloombergLP/bdlcc/Cache/setPostEvictionCallback.adoc[`setPostEvictionCallback`] | Set the post‐eviction callback to the specified `postEvictionCallback`. | xref:BloombergLP/bdlcc/Cache/size.adoc[`size`] | Return the current size of this cache. | xref:BloombergLP/bdlcc/Cache/tryGetValue.adoc[`tryGetValue`] | Load the value associated with the specified `key` into `value`. | xref:BloombergLP/bdlcc/Cache/visit.adoc[`visit`] | Call the specified `visitor` for every item in this cache. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlcc/Cache_TestUtil.adoc[BloombergLP::bdlcc::Cache_TestUtil]` | Test utility that exposes the cache RW‐mutex lock methods. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#