TDiscardableKeyValueCache

Implements a thread-safe discardable Key/Value cache by using two maps - a primary and a backfill.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Containers/DiscardableKeyValueCache.h

Include

#include "Containers/DiscardableKeyValueCache.h"

Syntax

template<class KeyType, class ValueType>
class TDiscardableKeyValueCache

Remarks

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

Variables

Name Description

Protected variable

TypedMap *

 

BackfillMap

Protected variable

TypedMap *

 

CurrentMap

Protected variable

FRWLock

 

LockObject

Protected variable

TypedMap

 

Map1

Protected variable

TypedMap

 

Map2

Constructors

Name Description

Public function

TDiscardableKeyValueCache()

Functions

Name Description

Public function

bool

 

Add

(
    const KeyType& Key,
    const ValueType& Value
)

Add an entry to the current map.

Public function

bool

 

Add

(
    const KeyType& Key,
    const ValueType& Value,
    const uint32 LockFlags
)

Add an entry to the current map.

Public function

uint32

 

ApplyLock

(
    uint32 CurrentFlags,
    uint32 NewFlags
)

Public function

TypedMap &

 

Backfill()

Reference to the current map

Public function

TypedMap &

 

Current()

Reference to the current map

Public function

int32

 

Discard()

Discard all items left in the backfill and swap the current & backfill pointers

Public function

int32

 

Discard

(
    DeleteFunc Func
)

Public function

int32

 

Discard

(
    uint32 InCurrentLockFlags,
    uint32& OutNewLockFlags,
    DeleteFunc Func
)

Discard all items in the backfill and swap the current & backfill pointers

Public function

bool

 

Find

(
    const KeyType& Key,
    ValueType& OutType
)

Returns true and sets OutType to the value with the associated key if it exists.

Public function

bool

 

Find

(
    const KeyType& Key,
    ValueType& OutType,
    uint32 InCurrentLockFlags,
    uint32& OutLockFlags
)

Externally-lock-aware Find function.

Protected function

bool

 

InternalFindWhileLocked

(
    const KeyType& Key,
    ValueType& OutType,
    uint32 InCurrentLockFlags,
    uint32& OutFlags
)

Checks for the entry in our current map, and if not found the backfill.

Public function

int32

 

Num()

Returns the total number of items in the cache

Public function

FRWLock &

 

RWLock()

Access to the internal locking object

Public function

void

 

Unlock

(
    uint32 Flags
)

Classes

Name

Description

Public struct

LockFlags

Flags used when calling Find()

Typedefs

Name

Description

TypedMap

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss