Cache.getOrCreateRaw

Gets an item from the cache or creates it if not already existing. If the item was found in the cache, its access time is updated, otherwise its create time is set.

Note that the create time is set only if an item is created, not if it already existed and you change the value referenced by the returned reference.

class Cache(size_t ValueSize = 0, bool TrackCreateTimes = false)
ValueRef
getOrCreateRaw
(
hash_t key
,
out bool existed
)
out (val) { static if (is_dynamic) { assert (val !is null); } else { assert (val.length == ValueSize); } }

Parameters

key hash_t

key to lookup

existed bool

true: the item already existed, false: the item was created

Return Value

Type: ValueRef

a reference to the value of the obtained or created item. If an item was created, the returned reference may refer to the value of a previously removed element.

Out: The returned reference is never null; for values of fixed size the slice length is ValueSize.

Meta