Methods |
public
|
set(string $key, mixed $value, DateTimeInterface|DateInterval|int|null $ttl = null): true
Store an item in the cache
Store an item in the cache
Parameters
$ttl |
The value's TTL in
seconds or as a {@see DateInterval}, a {@see DateTimeInterface}
representing its expiration time, or null if it should be cached
indefinitely.
|
|
#
|
public
|
has(string $key): bool
Check if an item is present in the cache and has not expired
Check if an item is present in the cache and has not expired
|
#
|
public
|
get(string $key, mixed $default = null): mixed
Retrieve an item from the cache
Retrieve an item from the cache
Returns
$default if the item has expired or doesn't exist.
|
#
|
public
|
getInstanceOf<T is object>(string $key, class-string<T> $class, T|null $default = null): T|null
Retrieve an instance of a class from the cache
Retrieve an instance of a class from the cache
Returns
$default if the item has expired, doesn't exist or is
not an instance of $class .
Implemented by
|
#
|
public
|
getArray(string $key, mixed[]|null $default = null): mixed[]|null
Retrieve an array from the cache
Retrieve an array from the cache
Returns
$default if the item has expired, doesn't exist or
is not an array.
Implemented by
|
#
|
public
|
getInt(string $key, ?int $default = null): int|null
Retrieve an integer from the cache
Retrieve an integer from the cache
Returns
$default if the item has expired, doesn't exist or is
not an integer.
Implemented by
|
#
|
public
|
getString(string $key, ?string $default = null): string|null
Retrieve a string from the cache
Retrieve a string from the cache
Returns
$default if the item has expired, doesn't exist or
is not a string.
Implemented by
|
#
|
public
|
delete(string $key): true
Delete an item from the cache
Delete an item from the cache
|
#
|
public
|
clear(): true
Delete all items from the cache
Delete all items from the cache
|
#
|
public
|
setMultiple(iterable<string, mixed> $values, DateTimeInterface|DateInterval|int|null $ttl = null): true
Store multiple items in the cache
Store multiple items in the cache
|
#
|
public
|
getMultiple(iterable<string> $keys, mixed $default = null): iterable<string, mixed>
Retrieve multiple items from the cache
Retrieve multiple items from the cache
|
#
|
public
|
deleteMultiple(iterable<string> $keys): true
Delete multiple items from the cache
Delete multiple items from the cache
|
#
|
public
|
getItemCount(): int
Get the number of unexpired items in the cache
Get the number of unexpired items in the cache
Implemented by
|
#
|
public
|
getItemKeys(): string[]
Get a list of unexpired items in the cache
Get a list of unexpired items in the cache
Implemented by
|
#
|
public
|
asOfNow(int|null $now = null): static
Get a copy of the cache where items do not expire over time
Get a copy of the cache where items do not expire over time
Returns an instance where items expire relative to the time of the call
to the method, allowing clients to mitigate race conditions like items
expiring or being replaced between subsequent calls.
Only one copy of the cache can be open at a time. Copies are closed via
{@see close()} or by going out of scope.
Parameters
$now |
If given, items expire relative to this Unix
timestamp instead of the time the method is called.
|
Throws
Implemented by
|
#
|
public
|
close(): void
Close the cache and any underlying resources
Close the cache and any underlying resources
If the cache is an instance returned by {@see asOfNow()}, the original
instance remains open after any locks held by the copy are released.
Implemented by
|
#
|