FailoverStore
class FailoverStore extends TaggableStore implements AuthoritativeRawReadable, CanFlushLocks, LockProvider, RawReadable
Constants
| protected FAILING_CACHES_CONTEXT_PREFIX |
Context key prefix for the caches which failed on the last action. Scoped per instance via spl_object_id() so multiple failover stores in the same coroutine don't share failure history. Stored in coroutine Context instead of an instance property because this store is a worker-lifetime singleton (cached in CacheManager::$stores). Instance state would leak across concurrent requests. |
Properties
| protected list<string> | $stores | The cache stores in failover order. |
Methods
Create a new failover store.
Retrieve an item from the cache by key.
Retrieve an item from the cache without unwrapping sentinels.
Retrieve an item without serving it from a non-authoritative read layer.
Retrieve multiple items from the cache by key.
Retrieve multiple items from the cache without unwrapping sentinels.
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.
Remove all expired tag set entries.
Determine if the store can currently flush locks.
Flush all locks managed by the store.
Determine if the lock store is separate from the cache store.
Get the cache key prefix.
Attempt the given operation until a store call does not throw.
Attempt the given method on every store.
Build failure history after an interrupted failover attempt.
Dispatch a newly observed store failure.
Get the cache store for the given store name.
Get every lock-capable backing store.
Details
in
TaggableStore at line 17
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 a NotSupportedException from tags() because Repository relies on the store to enforce its own conditional support.
in
TaggableStore at line 42
TagMode
getTagMode()
Get the tag mode this store operates under.
Default matches TaggableStore::tags() semantics (all-mode: keys are namespaced by the tag set). Subclasses override if they deviate.
at line 51
__construct(CacheManager $cache, Dispatcher $events, array $stores, string|null $failoverStoreName = null)
Create a new failover store.
at line 66
mixed
get(string $key)
Retrieve an item from the cache by key.
Store contract method — unwraps sentinels to null, matching the pre-refactor behavior (inner Repository's get() also unwrapped).
at line 74
mixed
getRaw(UnitEnum|string $key)
Retrieve an item from the cache without unwrapping sentinels.
at line 88
mixed
getAuthoritativeRaw(UnitEnum|string $key)
Retrieve an item without serving it from a non-authoritative read layer.
at line 106
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 117
array
manyRaw(array $keys)
Retrieve multiple items from the cache without unwrapping sentinels.
at line 129
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 137
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 145
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 153
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 161
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 169
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 177
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 185
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 193
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 201
bool
forget(string $key)
Remove an item from the cache.
at line 216
bool
flush()
Remove all items from the cache.
at line 234
array|null
flushStaleTags()
Remove all expired tag set entries.
at line 250
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 273
bool
flushLocks()
Flush all locks managed by the store.
at line 315
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.
at line 335
string
getPrefix()
Get the cache key prefix.
at line 348
protected mixed
attemptOnAllStores(Closure|string $method, array $arguments = [])
Attempt the given operation until a store call does not throw.
at line 396
protected array
attemptOnEveryStore(string $method, array $arguments)
Attempt the given method on every store.
at line 442
protected array
failureHistoryAfterInterruption(array $previousFailures, array $observedFailures, int $unattemptedFromPosition)
Build failure history after an interrupted failover attempt.
at line 459
protected void
recordStoreFailure(string $store, Throwable $exception, array $failingCaches)
Dispatch a newly observed store failure.
at line 473
protected Repository
store(string $store)
Get the cache store for the given store name.
at line 483
protected array
lockStores()
Get every lock-capable backing store.