#include <memoizationcache.h>
Allows to store objects for possible reuse within a global cache. All functions are thread safe.
Static Public Member Functions | |
static MAXON_METHOD Result< GenericDataRef > | Get (LiteralId &&type, const void *documentRelated, Int runId, UniqueHash hash, const Delegate< Result< GenericDataRef >()> &lambda, Bool &created=BoolLValue()) |
static MAXON_METHOD void | FlushAll (LiteralId &&type, const void *documentRelated, Int removeRunId) |
static MAXON_METHOD Result< void > | GetStatistics (HashMap< Id, Tuple< Int, Int >> &result) |
Private Member Functions | |
MAXON_INTERFACE_NONVIRTUAL (MemoizationCacheInterface, MAXON_REFERENCE_STATIC, "net.maxon.command.interface.memoizationcache", MAXON_IMPLEMENTATION_MODULE("net.maxon.command")) | |
|
private |
|
static |
Gets or creates a object. If the object is not cached the lambda is called to create a new object. The caller is responsible to clone the data from the GenericData of the result.
[in] | type | Category of the cache. See MemoizationTypes::... |
[in] | documentRelated | Pointer to an object (e.g. BaseDocument) to which the object belongs to. |
[in] | runId | Timestamp of the cache object. In cc4d you can use BaseDocument::GetCacheRunId() to pass the value. |
[in] | hash | Unique hash of the cache object. |
[in] | lambda | Delegate which is called to create an object if no cache was found for the given hash. |
[out] | created | Returns True if no cache was found and the object was created. |
|
static |
Flushes the caches. The caller can flush all by giving default parameters of selective by id or pointer.
[in] | type | If type.IsPopulated() the Flush function selects only the given types. |
[in] | documentRelated | If documentRelated != nullptr the function deletes only caches belonging to this pointer. |
[in] | removeRunId | If removeRunId != NOTOK all values older or equal to this runId are deleted. |
Returns the current cache usage by type, count etc.
[out] | result | The given HashMap is filled in the function call. LiteralId - the MemoizationTypes::..., Int cnt - the number of entries of the cache, Int mem - memory usage by this entry. |