class StackStore extends TaggableStore implements AuthoritativeRawReadable, CanFlushLocks, LockProvider

Properties

protected StackStoreProxy> $stores

The ordered store layers.

protected false|string|null $tagCompositionError

Memoized tag-composition validation error.

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(array $stores)

No description

mixed
get(string $key)

Retrieve an item from the cache by key.

mixed
getAuthoritativeRaw(UnitEnum|string $key)

Retrieve an item from the authoritative bottom layer without backfilling upper layers.

array
many(array $keys)

Retrieve multiple items from the cache by key.

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|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.

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.

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
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.

array
taggableLayers()

Get the underlying taggable layer stores, top to bottom.

array|null
getOrRestoreRecord(string $key)

No description

void
restoreRecords(array $records, array $layers)

Restore records found in lower layers into the layers above them.

bool
putRecord(string $key, array $record)

No description

bool
putRecordTagged(array $tags, string $key, array $record)

Store a record in all layers, indexing it under the given tags in the taggable layers.

bool
putToStore(StackStoreProxy $store, string $key, array $record)

Store a record in a single layer.

array
normalizeRecord(array $record)

Normalize a record to an absolute expiration and its remaining TTL.

bool
putToStoreTagged(StackStoreProxy $proxy, array $tags, string $key, array $record)

Store a record in a single layer via the layer's tagged write path when possible.

bool|int
incrementTagged(array $tags, string $key, int $value = 1)

Increment a record's value, indexing the write under the given tags.

void
ensureTagCompositionIsValid()

Ensure the layer composition can support stack tags.

string|null
tagCompositionError()

No description

string|null
validateTagComposition()

Validate the layer composition for tag support.

bottomStore()

Get the bottom layer's underlying store.

bottomLockProvider()

Get the bottom layer's store as a lock provider.

mixed
callStoresStacked(Closure $handler, Closure $bottomLayer)

No description

bool
callStores(Closure $handler, Closure|null $rollback = null, bool $rollbackFailedStore = false)

Call the handler for each store in order, rolling back the completed stores when one fails.

bool
callAllStores(Closure $handler)

Call the handler for every store.

Details

at line 299
TaggedCache tags(mixed $names)

Begin executing a new tags operation.

Parameters

mixed $names

Return Value

TaggedCache

Exceptions

NotSupportedException

at line 309
bool supportsTags()

Determine if this store currently supports tags.

Return Value

bool

at line 319
TagMode getTagMode()

Get the tag mode this store operates under.

Return Value

TagMode

Exceptions

NotSupportedException

at line 45
__construct(array $stores)

No description

Parameters

array $stores

Exceptions

InvalidArgumentException

at line 57
mixed get(string $key)

Retrieve an item from the cache by key.

Parameters

string $key

Return Value

mixed

at line 67
mixed getAuthoritativeRaw(UnitEnum|string $key)

Retrieve an item from the authoritative bottom layer without backfilling upper layers.

Parameters

UnitEnum|string $key

Return Value

mixed

at line 84
array many(array $keys)

Retrieve multiple items from the cache by key.

Parameters

array $keys

Return Value

array

at line 117
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 130
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 173
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 191
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 196
bool forever(string $key, mixed $value)

Store an item in the cache indefinitely.

Parameters

string $key
mixed $value

Return Value

bool

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

Adjust the expiration time of a cached item.

Parameters

string $key
int $seconds

Return Value

bool

at line 223
bool forget(string $key)

Remove an item from the cache.

Parameters

string $key

Return Value

bool

at line 228
bool flush()

Remove all items from the cache.

Return Value

bool

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

Get a lock instance.

Locks are delegated to the bottom layer and never touch the cache tiers.

Parameters

string $name
int $seconds
string|null $owner

Return Value

Lock

Exceptions

NotSupportedException

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

Restore a lock instance using the owner identifier.

Parameters

string $name
string $owner

Return Value

Lock

Exceptions

NotSupportedException

at line 258
bool supportsFlushingLocks()

Determine if the store can currently flush locks.

Return Value

bool

at line 270
bool flushLocks()

Flush all locks managed by the store.

Return Value

bool

Exceptions

NotSupportedException

at line 287
bool hasSeparateLockStore()

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

Return Value

bool

at line 326
string getPrefix()

Get the cache key prefix.

Return Value

string

at line 338
array taggableLayers()

Get the underlying taggable layer stores, top to bottom.

Return Value

array

Exceptions

NotSupportedException

at line 355
protected array|null getOrRestoreRecord(string $key)

No description

Parameters

string $key

Return Value

array|null

at line 384
protected void restoreRecords(array $records, array $layers)

Restore records found in lower layers into the layers above them.

Mirrors getOrRestoreRecord(), filling the deepest layer first, but writes each layer's records with one putMany() per remaining TTL.

Parameters

array $records
array $layers

the index of the layer each record was found in

Return Value

void

at line 423
protected bool putRecord(string $key, array $record)

No description

Parameters

string $key
array $record

Return Value

bool

at line 436
bool putRecordTagged(array $tags, string $key, array $record)

Store a record in all layers, indexing it under the given tags in the taggable layers.

Parameters

array $tags
string $key
array $record

Return Value

bool

at line 447
protected bool putToStore(StackStoreProxy $store, string $key, array $record)

Store a record in a single layer.

Parameters

StackStoreProxy $store
string $key
array $record

Return Value

bool

at line 472
protected array normalizeRecord(array $record)

Normalize a record to an absolute expiration and its remaining TTL.

Records without an expiration or TTL are returned unchanged with a null TTL. A non-positive TTL means the record has no remaining lifetime (for example, it expired while a lower layer was read), so callers must not write it: array stores keep non-positive TTL writes forever.

Parameters

array $record

Return Value

array

at line 493
protected bool putToStoreTagged(StackStoreProxy $proxy, array $tags, string $key, array $record)

Store a record in a single layer via the layer's tagged write path when possible.

Tagged writes bypass StackStoreProxy, so this mirrors putToStore()'s TTL clamp.

Parameters

StackStoreProxy $proxy
array $tags
string $key
array $record

Return Value

bool

at line 528
bool|int incrementTagged(array $tags, string $key, int $value = 1)

Increment a record's value, indexing the write under the given tags.

Parameters

array $tags
string $key
int $value

Return Value

bool|int

at line 551
protected void ensureTagCompositionIsValid()

Ensure the layer composition can support stack tags.

Return Value

void

Exceptions

NotSupportedException

at line 558
protected string|null tagCompositionError()

No description

Return Value

string|null

at line 573
protected string|null validateTagComposition()

Validate the layer composition for tag support.

A non-taggable or all-mode layer below the taggable region would resurrect flushed values on read-through, silently undoing invalidation.

Return Value

string|null

at line 615
protected Store bottomStore()

Get the bottom layer's underlying store.

Return Value

Store

at line 625
protected LockProvider bottomLockProvider()

Get the bottom layer's store as a lock provider.

Return Value

LockProvider

Exceptions

NotSupportedException

at line 639
protected mixed callStoresStacked(Closure $handler, Closure $bottomLayer)

No description

Parameters

Closure $handler
Closure $bottomLayer

Return Value

mixed

at line 651
protected bool callStores(Closure $handler, Closure|null $rollback = null, bool $rollbackFailedStore = false)

Call the handler for each store in order, rolling back the completed stores when one fails.

Parameters

Closure $handler
Closure|null $rollback
bool $rollbackFailedStore

Return Value

bool

at line 712
protected bool callAllStores(Closure $handler)

Call the handler for every store.

Parameters

Closure $handler

Return Value

bool