Methods |
public
|
get(string $key, mixed $default = null): mixed
Fetches a value from the cache.
Fetches a value from the cache.
Parameters
$key |
The unique key of this item in the cache.
|
$default |
Default value to return if the key does not exist.
|
Returns
The value of the item from the cache, or $default in case of cache miss.
Throws
Implemented by
|
#
|
public
|
set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
Parameters
$key |
The key of the item to store.
|
$value |
The value of the item to store, must be serializable.
|
$ttl |
Optional. The TTL value of this item. If no value is sent and
the driver supports TTL then the library may set a default value
for it or let the driver take care of that.
|
Returns
True on success and false on failure.
Throws
Implemented by
|
#
|
public
|
delete(string $key): bool
Delete an item from the cache by its unique key.
Delete an item from the cache by its unique key.
Parameters
$key |
The unique cache key of the item to delete.
|
Returns
True if the item was successfully removed. False if there was an error.
Throws
Implemented by
|
#
|
public
|
clear(): bool
Wipes clean the entire cache's keys.
Wipes clean the entire cache's keys.
Returns
True on success and false on failure.
Implemented by
|
#
|
public
|
getMultiple(iterable $keys, mixed $default = null): iterable
Obtains multiple cache items by their unique keys.
Obtains multiple cache items by their unique keys.
Parameters
$keys |
A list of keys that can obtained in a single operation.
|
$default |
Default value to return for keys that do not exist.
|
Returns
A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
Throws
Implemented by
|
#
|
public
|
setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
Persists a set of key => value pairs in the cache, with an optional TTL.
Persists a set of key => value pairs in the cache, with an optional TTL.
Parameters
$values |
A list of key => value pairs for a multiple-set operation.
|
$ttl |
Optional. The TTL value of this item. If no value is sent and
the driver supports TTL then the library may set a default value
for it or let the driver take care of that.
|
Returns
True on success and false on failure.
Throws
Implemented by
|
#
|
public
|
deleteMultiple(iterable $keys): bool
Deletes multiple cache items in a single operation.
Deletes multiple cache items in a single operation.
Parameters
$keys |
A list of string-based keys to be deleted.
|
Returns
True if the items were successfully removed. False if there was an error.
Throws
Implemented by
|
#
|
public
|
has(string $key): bool
Determines whether an item is present in the cache.
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.
Parameters
Throws
Implemented by
|
#
|