Navigation
API > API/Runtime > API/Runtime/Core
Implements a thread-safe discardable Key/Value cache by using two maps - a primary and a backfill.
Find() checks the current map first then the backfill. Entries found in the backfill are moved into the primary map.
When Swap is called all items in the backfill are removed and the currentmap & backfill are swapped.
This results in most recently used items being retained and older/unused items being evicted. The more often Swap is called the shorter the lifespan for items
| Name | TDiscardableKeyValueCache |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/DiscardableKeyValueCache.h |
| Include Path | #include "Containers/DiscardableKeyValueCache.h" |
Syntax
template<class KeyType, class ValueType>
class TDiscardableKeyValueCache
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TDiscardableKeyValueCache() |
Containers/DiscardableKeyValueCache.h |
Structs
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| TypedMap | TMap< KeyType, ValueType > | Containers/DiscardableKeyValueCache.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool Add
(
const KeyType& Key, |
Add an entry to the current map. | Containers/DiscardableKeyValueCache.h | |
bool Add
(
const KeyType& Key, |
Add an entry to the current map. | Containers/DiscardableKeyValueCache.h | |
uint32 ApplyLock
(
uint32 CurrentFlags, |
Containers/DiscardableKeyValueCache.h | ||
TypedMap & Backfill() |
Reference to the current map | Containers/DiscardableKeyValueCache.h | |
TypedMap & Current() |
Reference to the current map | Containers/DiscardableKeyValueCache.h | |
int32 Discard () |
Discard all items left in the backfill and swap the current & backfill pointers | Containers/DiscardableKeyValueCache.h | |
int32 Discard
(
DeleteFunc Func |
Containers/DiscardableKeyValueCache.h | ||
int32 Discard
(
uint32 InCurrentLockFlags, |
Discard all items in the backfill and swap the current & backfill pointers | Containers/DiscardableKeyValueCache.h | |
bool Find
(
const KeyType& Key, |
Returns true and sets OutType to the value with the associated key if it exists. | Containers/DiscardableKeyValueCache.h | |
bool Find
(
const KeyType& Key, |
Externally-lock-aware Find function. | Containers/DiscardableKeyValueCache.h | |
int32 Num() |
Returns the total number of items in the cache | Containers/DiscardableKeyValueCache.h | |
FRWLock & RWLock() |
Access to the internal locking object | Containers/DiscardableKeyValueCache.h | |
void Unlock
(
uint32 Flags |
Containers/DiscardableKeyValueCache.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool InternalFindWhileLocked
(
const KeyType& Key, |
Checks for the entry in our current map, and if not found the backfill. | Containers/DiscardableKeyValueCache.h |