PriorityCache.getOrCreate

Get an item with a given key if it already existed or creates a new item with the given priority if it didn't exist.

Beware that in case an item didn't exist it is still possible that a new item will NOT be created if whenNewAndLeastPriority() implementation prefers the already existing item over the new one. The default implementation of whenNewAndLeastPriority() always creates a new one.

class PriorityCache(T)
T*
getOrCreate
(
hash_t key
,
lazy ulong priority
,
out bool existed
,
bool tracK_get_miss = true
)

Parameters

key hash_t

item's key

priority ulong

the priority to update to assign to the new item if no item already exists

existed bool

will be assigned to true if the item already existed and wasn't created

tracK_get_miss bool

flags whether not finding the item should count as a cache miss

Return Value

Type: T*

The existing or created item or null if no item was found or created.

Meta