class FailoverStore extends TaggableStore implements 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.

Methods

tags(mixed $names)

Begin executing a new tags operation.

bool
supportsTags()

Determine if this store currently supports tags.

TagMode
getTagMode()

Get the tag mode this store operates under.

__construct(CacheManager $cache, Dispatcher $events, array $stores)

Create a new failover store.

mixed
get(string $key)

Retrieve an item from the cache by key.

mixed
getRaw(UnitEnum|string $key)

Retrieve an item from the cache by key without unwrapping sentinels.

array
many(array $keys)

Retrieve multiple items from the cache by key.

array
manyRaw(array $keys)

Retrieve multiple items by key without unwrapping sentinels.

bool
put(string $key, mixed $value, int $seconds)

Store an item in the cache for a given number of seconds.

bool
putMany(array $values, int $seconds)

Store multiple items in the cache for a given number of seconds.

bool
add(string $key, mixed $value, int $seconds)

Store an item in the cache if the key doesn't exist.

bool|int
increment(string $key, int $value = 1)

Increment the value of an item in the cache.

bool|int
decrement(string $key, int $value = 1)

Decrement the value of an item in the cache.

bool
forever(string $key, mixed $value)

Store an item in the cache indefinitely.

lock(string $name, int $seconds = 0, string|null $owner = null)

Get a lock instance.

restoreLock(string $name, string $owner)

Restore a lock instance using the owner identifier.

bool
touch(string $key, int $seconds)

Adjust the expiration time of a cached item.

bool
forget(string $key)

Remove an item from the cache.

bool
flush()

Remove all items from the cache.

array|null
flushStaleTags()

Remove all expired tag set entries.

bool
supportsFlushingLocks()

Determine if the store can currently flush locks.

bool
flushLocks()

Flush all locks managed by the store.

bool
hasSeparateLockStore()

Determine if the lock store is separate from the cache store.

string
getPrefix()

Get the cache key prefix.

mixed
attemptOnAllStores(string $method, array $arguments)

Attempt the given method until a store call does not throw.

array
attemptOnEveryStore(string $method, array $arguments)

Attempt the given method on every store.

void
recordStoreFailure(string $store, Throwable $exception, array $failingCaches)

Dispatch a newly observed store failure.

store(string $store)

Get the cache store for the given store name.

array
lockStores()

Get every lock-capable backing store.

Details

in TaggableStore at line 17
TaggedCache tags(mixed $names)

Begin executing a new tags operation.

Parameters

mixed $names

Return Value

TaggedCache

Exceptions

NotSupportedException

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.

Return Value

bool

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.

Return Value

TagMode

at line 41
__construct(CacheManager $cache, Dispatcher $events, array $stores)

Create a new failover store.

Parameters

CacheManager $cache
Dispatcher $events
array $stores

at line 54
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).

Parameters

string $key

Return Value

mixed

at line 59
mixed getRaw(UnitEnum|string $key)

Retrieve an item from the cache by key without unwrapping sentinels.

Parameters

UnitEnum|string $key

Return Value

mixed

the raw stored value — may be null (genuine miss), Hypervel\Cache\NullSentinel::VALUE (cached-null via the nullable cache methods), or a real cached value

at line 71
array many(array $keys)

Retrieve multiple items from the cache by key.

Items not found in the cache will have a null value.

Parameters

array $keys

Return Value

array

at line 79
array manyRaw(array $keys)

Retrieve multiple items by key without unwrapping sentinels.

Parameters

array $keys

Return Value

array

keyed by the input keys; values are raw (may include null, NullSentinel::VALUE, or real values)

at line 87
bool put(string $key, mixed $value, int $seconds)

Store an item in the cache for a given number of seconds.

Parameters

string $key
mixed $value
int $seconds

Return Value

bool

at line 95
bool putMany(array $values, int $seconds)

Store multiple items in the cache for a given number of seconds.

Parameters

array $values
int $seconds

Return Value

bool

at line 103
bool add(string $key, mixed $value, int $seconds)

Store an item in the cache if the key doesn't exist.

Parameters

string $key
mixed $value
int $seconds

Return Value

bool

at line 111
bool|int increment(string $key, int $value = 1)

Increment the value of an item in the cache.

Parameters

string $key
int $value

Return Value

bool|int

at line 119
bool|int decrement(string $key, int $value = 1)

Decrement the value of an item in the cache.

Parameters

string $key
int $value

Return Value

bool|int

at line 127
bool forever(string $key, mixed $value)

Store an item in the cache indefinitely.

Parameters

string $key
mixed $value

Return Value

bool

at line 135
Lock lock(string $name, int $seconds = 0, string|null $owner = null)

Get a lock instance.

Parameters

string $name
int $seconds
string|null $owner

Return Value

Lock

at line 143
Lock restoreLock(string $name, string $owner)

Restore a lock instance using the owner identifier.

Parameters

string $name
string $owner

Return Value

Lock

at line 151
bool touch(string $key, int $seconds)

Adjust the expiration time of a cached item.

Parameters

string $key
int $seconds

Return Value

bool

at line 159
bool forget(string $key)

Remove an item from the cache.

Parameters

string $key

Return Value

bool

at line 174
bool flush()

Remove all items from the cache.

Return Value

bool

at line 192
array|null flushStaleTags()

Remove all expired tag set entries.

Return Value

array|null

at line 208
bool supportsFlushingLocks()

Determine if the store can currently flush locks.

Return Value

bool

at line 231
bool flushLocks()

Flush all locks managed by the store.

Return Value

bool

Exceptions

BadMethodCallException
Throwable

at line 271
bool hasSeparateLockStore()

Determine if the lock store is separate from the cache store.

Return Value

bool

at line 291
string getPrefix()

Get the cache key prefix.

Return Value

string

at line 301
protected mixed attemptOnAllStores(string $method, array $arguments)

Attempt the given method until a store call does not throw.

Parameters

string $method
array $arguments

Return Value

mixed

Exceptions

Throwable

at line 333
protected array attemptOnEveryStore(string $method, array $arguments)

Attempt the given method on every store.

Parameters

string $method
array $arguments

Return Value

array

at line 364
protected void recordStoreFailure(string $store, Throwable $exception, array $failingCaches)

Dispatch a newly observed store failure.

Parameters

string $store
Throwable $exception
array $failingCaches

Return Value

void

at line 378
protected Repository store(string $store)

Get the cache store for the given store name.

Parameters

string $store

Return Value

Repository

at line 388
protected array lockStores()

Get every lock-capable backing store.

Return Value

array