$Cache¶
$Cache is a global object that can be used to store and retrieve objects in a non-persistent cache storage.
1 | |
Remarks¶
The cache is cleared when the application is restarted or when an item expires.
The cache also provides a locking mechanism for shared access to objects. The locking mechanism is based on a token value. The token value is generated by the $Cache.Lock or $Cache.TryLock method. The token value must be used to release the lock with the $Cache.ReleaseLock method. If the lock is not released before the timeout, it is automatically released after the transaction is completed.
Examples¶
Cache a lookup list¶
1 2 3 4 5 6 7 8 9 10 | |
Capabilities¶
Cache Storage¶
$Cache.Get: Retrieves a cached value by its key, if it exists.$Cache.Set: Stores an object in the cache.
Locking¶
$Cache.Lock: Attempts to acquire a lock for the specified key, blocking until the lock is acquired.$Cache.LockAsync: Asynchronously attempts to acquire a lock without blocking the script execution thread while waiting.$Cache.ReleaseLock: Releases a previously acquired lock.$Cache.ReleaseLockAsync: Asynchronously releases a previously acquired lock.$Cache.TryLock: Attempts to acquire a lock for a shared key without blocking.$Cache.TryLockAsync: Asynchronously performs one immediate lock acquisition attempt.