CRM_Utils_Cache_FastArrayDecorator
class CRM_Utils_Cache_FastArrayDecorator implements CRM_Utils_Cache_Interface
Class CRM_Utils_Cache_FastArrayDecorator
Like CRM_Utils_Cache_ArrayDecorator, this creates a two-tier cache. But it's... faster. The speed improvements are achieved by sacrificing compliance with PSR-16. Specific trade-offs:
- TTL values are not tracked locally. Any data cached locally will stay active until the instance is destroyed (i.e. until the request ends). You won't notice this is you have short-lived requests and long-lived caches.
- If you store an object in the local cache, the same object instance will be used through the end of the request. If you modify a property of the object, the change will endure within the current pageview but will not pass-through to the persistent cache.
But... it is twice as fast (on high-volume reads).
Ex: $cache = new CRM_Utils_Cache_FastArrayDecorator(new CRM_Utils_Cache_Redis(...));
Traits
Properties
protected int | $defaultTimeout |
Methods
Obtains multiple cache items by their unique keys.
Persists a set of key => value pairs in the cache, with an optional TTL.
Deletes multiple cache items in a single operation.
CRM_Utils_Cache_FastArrayDecorator constructor.
Get a value from the cache.
Delete a value from the cache.
Delete all values from the cache.
Delete all values from the cache.
Determines whether an item is present in the cache.
Details
in CRM_Utils_Cache_NaiveMultipleTrait at line 53
iterable
getMultiple(iterable $keys, mixed $default = NULL)
Obtains multiple cache items by their unique keys.
in CRM_Utils_Cache_NaiveMultipleTrait at line 77
bool
setMultiple(iterable $values, null|int|DateInterval $ttl = NULL)
Persists a set of key => value pairs in the cache, with an optional TTL.
in CRM_Utils_Cache_NaiveMultipleTrait at line 101
bool
deleteMultiple(iterable $keys)
Deletes multiple cache items in a single operation.
at line 83
__construct(CRM_Utils_Cache_Interface $delegate, int $defaultTimeout = 3600)
CRM_Utils_Cache_FastArrayDecorator constructor.
at line 88
bool
set(string $key, mixed $value, null|int|DateInterval $ttl = NULL)
Set the value in the cache.
at line 102
mixed
get(string $key, mixed $default = NULL)
Get a value from the cache.
at line 118
bool
delete(string $key)
Delete a value from the cache.
at line 124
bool
flush()
Delete all values from the cache.
NOTE: flush() and clear() should be aliases. flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16.
at line 128
bool
clear()
Delete all values from the cache.
NOTE: flush() and clear() should be aliases. flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16.
at line 133
bool
has(string $key)
Determines whether an item is present in the cache.
NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, another script can remove it making the state of your app out of date.