Methods |
public
|
set(string $key, mixed $value, DateTimeInterface|DateInterval|int|null $ttl = null): true
Store an item under a given key
Store an item under a given key
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 exists and has not expired
Check if an item exists and has not expired
|
#
|
public
|
get(string $key, mixed $default = null): mixed
Retrieve an item stored under a given key
Retrieve an item stored under a given key
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 stored under a given key
Retrieve an instance of a class stored under a given key
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 stored under a given key
Retrieve an array stored under a given key
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 stored under a given key
Retrieve an integer stored under a given key
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 stored under a given key
Retrieve a string stored under a given key
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 stored under a given key
Delete an item stored under a given key
|
#
|
public
|
clear(): true
Delete all items
|
#
|
public
|
setMultiple(iterable<string, mixed> $values, DateTimeInterface|DateInterval|int|null $ttl = null): true
Store items under the given keys
Store items under the given keys
|
#
|
public
|
getMultiple(iterable<string> $keys, mixed $default = null): iterable<string, mixed>
Retrieve items stored under the given keys
Retrieve items stored under the given keys
|
#
|
public
|
deleteMultiple(iterable<string> $keys): true
Delete items stored under the given keys
Delete items stored under the given keys
|
#
|
public
|
getItemCount(): int
Get the number of unexpired items in the store
Get the number of unexpired items in the store
Implemented by
|
#
|
public
|
getItemKeys(): string[]
Get a list of keys under which unexpired items are stored
Get a list of keys under which unexpired items are stored
Implemented by
|
#
|
public
|
asOfNow(int|null $now = null): static
Get a copy of the store where items do not expire over time
Get a copy of the store where items do not expire over time
Returns an instance where items expire relative to the time of the call
to {@see asOfNow()}, allowing clients to mitigate race conditions like
items expiring or being replaced between subsequent calls.
Only one copy of the store 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 {@see asOfNow()} is called.
|
Throws
LogicException |
if the store is a copy, or if another copy of the
store is open.
|
Implemented by
|
#
|
public
|
close(): void
Close the store and any underlying resources
Close the store and any underlying resources
If the store is an instance returned by {@see asOfNow()}, the original
instance remains open after any locks held by the copy are released.
Implemented by
|
#
|