RedisStore
class RedisStore extends TaggableStore implements CanFlushLocks, LockProvider
Properties
| protected Factory | $redis | ||
| protected string | $prefix | A string that should be prepended to keys. |
|
| protected string | $connection | The Redis connection instance that should be used to manage locks. |
|
| protected string | $lockConnection | The name of the connection that should be used for locks. |
|
| protected TagMode | $tagMode | The tag mode (All or Any). |
|
| protected array|bool|null | $serializableClasses | The classes that should be allowed during unserialization. |
|
| protected SerializableClassPolicy|null | $serializableClassPolicy | The shared serializable class policy. |
Methods
Begin executing a new tags operation.
Get the tag mode.
Create a new Redis store.
Retrieve an item from the cache by key.
Retrieve multiple items from the cache by key.
Store an item in the cache for a given number of seconds.
Store multiple items in the cache for a given number of seconds.
Store an item in the cache if the key doesn't exist.
Increment the value of an item in the cache.
Decrement the value of an item in the cache.
Store an item in the cache indefinitely.
Restore a lock instance using the owner identifier.
Adjust the expiration time of a cached item.
Remove an item from the cache.
Remove all items from the cache.
Determine if the store can currently flush locks.
Remove all locks from the store.
Get the any tag operations container.
Get the all tag operations container.
Remove all expired tag set entries.
Set the tag mode.
Pin a pool connection for the duration of a callback.
Get the Redis connection instance.
Get the Redis connection instance that should be used to manage locks.
Determine if the lock store is separate from the cache store.
Specify the name of the connection that should be used to store data.
Specify the name of the connection that should be used to manage locks.
Get the cache key prefix.
Set the cache key prefix.
Get the StoreContext instance.
Get the Serialization instance.
Details
at line 292
TaggedCache
tags(mixed $names)
Begin executing a new tags operation.
in
TaggableStore at line 31
bool
supportsTags()
Determine if this store currently supports tags.
Stores whose tag support depends on configuration or composition override this; for everything else extending TaggableStore, tag support is unconditional. A store that can return false here must also throw from tags() because Repository relies on the store to enforce its own conditional support.
at line 353
TagMode
getTagMode()
Get the tag mode.
at line 112
__construct(Factory $redis, string $prefix = '', string $connection = 'default', array|bool|null $serializableClasses = null, SerializableClassPolicy|null $serializableClassPolicy = null)
Create a new Redis store.
at line 129
mixed
get(string $key)
Retrieve an item from the cache by key.
at line 138
array
many(array $keys)
Retrieve multiple items from the cache by key.
Items not found in the cache will have a null value.
at line 146
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 154
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 162
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 170
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 178
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 186
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 194
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 202
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 210
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 222
bool
forget(string $key)
Remove an item from the cache.
at line 234
bool
flush()
Remove all items from the cache.
at line 242
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 252
bool
flushLocks()
Remove all locks from the store.
at line 268
AnyTagOperations
anyTagOps()
Get the any tag operations container.
Use this to access all any-mode tagged cache operations.
at line 281
AllTagOperations
allTagOps()
Get the all tag operations container.
Use this to access all all-mode tagged cache operations.
at line 317
array|null
flushStaleTags()
Remove all expired tag set entries.
Returns an array of snake_case stat keys with integer values, or null if no stats are available.
at line 338
RedisStore
setTagMode(TagMode|string $mode)
Set the tag mode.
Any mode requires Redis 8.0 or later, Valkey 9.0 or later, and PhpRedis 6.3.0 or later. These additional requirements do not apply to all mode.
Mutates state on a per-worker singleton; runtime mutation races across coroutines.
at line 369
mixed
withPinnedConnection(callable $callback)
Pin a pool connection for the duration of a callback.
All Redis operations inside the callback reuse the same connection, avoiding multiple pool checkouts.
at line 377
RedisProxy
connection()
Get the Redis connection instance.
at line 385
RedisProxy
lockConnection()
Get the Redis connection instance that should be used to manage locks.
at line 393
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.
at line 405
void
setConnection(string|null $connection)
Specify the name of the connection that should be used to store data.
Persists on the cached store for the worker lifetime and triggers cache invalidation of resolved operations; per-request use races across coroutines.
at line 420
RedisStore
setLockConnection(string $connection)
Specify the name of the connection that should be used to manage locks.
Persists on the cached store for the worker lifetime; per-request use races across coroutines.
at line 431
string
getPrefix()
Get the cache key prefix.
at line 439
Factory
getRedis()
Get the Redis database instance.
at line 451
void
setPrefix(string|null $prefix)
Set the cache key prefix.
Persists on the cached store for the worker lifetime and triggers cache invalidation of resolved operations; per-request use races across coroutines.
at line 461
StoreContext
getContext()
Get the StoreContext instance.
at line 474
Serialization
getSerialization()
Get the Serialization instance.