BaseHandler
in package
implements
CacheInterface
Base class for cache handling
Tags
Table of Contents
Interfaces
- CacheInterface
- Cache interface
Constants
- MAX_KEY_LENGTH = PHP_INT_MAX
- Maximum key length.
- RESERVED_CHARACTERS = '{}()/\@:'
- Reserved characters that cannot be used in a key or tag. May be overridden by the config.
Properties
- $prefix : string
- Prefix to apply to cache keys.
Methods
- deleteMatching() : int|never
- Deletes items from the cache store matching a given pattern.
- remember() : array<string|int, mixed>|bool|float|int|object|string|null
- Get an item from the cache, or execute the given Closure and store the result.
- validateKey() : string
- Validates a cache key according to PSR-6.
Constants
MAX_KEY_LENGTH
Maximum key length.
public
mixed
MAX_KEY_LENGTH
= PHP_INT_MAX
RESERVED_CHARACTERS
Reserved characters that cannot be used in a key or tag. May be overridden by the config.
in favor of the Cache config
public
mixed
RESERVED_CHARACTERS
= '{}()/\@:'
From https://github.com/symfony/cache-contracts/blob/c0446463729b89dd4fa62e9aeecc80287323615d/ItemInterface.php#L43
Properties
$prefix
Prefix to apply to cache keys.
protected
string
$prefix
May not be used by all handlers.
Methods
deleteMatching()
Deletes items from the cache store matching a given pattern.
public
deleteMatching(string $pattern) : int|never
Parameters
- $pattern : string
-
Cache items glob-style pattern
Tags
Return values
int|neverremember()
Get an item from the cache, or execute the given Closure and store the result.
public
remember(string $key, int $ttl, callable(): mixed $callback) : array<string|int, mixed>|bool|float|int|object|string|null
Parameters
- $key : string
-
Cache item name
- $ttl : int
-
Time to live
- $callback : callable(): mixed
-
Callback return value
Return values
array<string|int, mixed>|bool|float|int|object|string|nullvalidateKey()
Validates a cache key according to PSR-6.
public
static validateKey(string $key[, string $prefix = '' ]) : string
Keys that exceed MAX_KEY_LENGTH are hashed. From https://github.com/symfony/cache/blob/7b024c6726af21fd4984ac8d1eae2b9f3d90de88/CacheItem.php#L158
Parameters
- $key : string
-
The key to validate
- $prefix : string = ''
-
Optional prefix to include in length calculations