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. Entries pair a weak owner with its failure list. A dead or different owner means no history, since released object IDs may be reused within a coroutine. 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 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 52
__construct(CacheManager $cache, Dispatcher $events, array $stores, string|null $failoverStoreName = null)
Create a new failover store.
at line 67
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 75
mixed
getRaw(UnitEnum|string $key)
Retrieve an item from the cache without unwrapping sentinels.
at line 89
mixed
getAuthoritativeRaw(UnitEnum|string $key)
Retrieve an item without serving it from a non-authoritative read layer.
at line 107
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 118
array
manyRaw(array $keys)
Retrieve multiple items from the cache without unwrapping sentinels.
at line 130
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 138
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 146
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 154
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 162
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 170
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 178
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 186
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 194
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 202
bool
forget(string $key)
Remove an item from the cache.
at line 217
bool
flush()
Remove all items from the cache.
at line 235
array|null
flushStaleTags()
Remove all expired tag set entries.
at line 251
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 274
bool
flushLocks()
Flush all locks managed by the store.
at line 318
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.
at line 338
string
getPrefix()
Get the cache key prefix.
at line 351
protected mixed
attemptOnAllStores(Closure|string $method, array $arguments = [])
Attempt the given operation until a store call does not throw.
at line 400
protected array
attemptOnEveryStore(string $method, array $arguments)
Attempt the given method on every store.
at line 470
protected array
failureHistoryAfterInterruption(array $previousFailures, array $observedFailures, int $unattemptedFromPosition)
Build failure history after an interrupted failover attempt.
at line 487
protected void
recordStoreFailure(string $store, Throwable $exception, array $failingCaches)
Dispatch a newly observed store failure.
at line 501
protected Repository
store(string $store)
Get the cache store for the given store name.
at line 511
protected array
lockStores()
Get every lock-capable backing store.