abstract class AbstractArrayStore extends TaggableStore implements CanFlushLocks, LockProvider

Traits

Fallback implementations for stores without native multi-key operations.

Properties

protected bool $serializesValues

Indicates if values are serialized within the store.

protected array|bool|null $serializableClasses

The classes that should be allowed during unserialization.

protected SerializableClassPolicy|null $serializableClassPolicy

The shared serializable class policy.

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.

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

array
many(array $keys)

Retrieve multiple items from the cache by key.

bool
putMany(array $values, int $seconds)

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

__construct(bool $serializesValues = false, array|bool|null $serializableClasses = null, SerializableClassPolicy|null $serializableClassPolicy = null)

Create a new array-family store.

array
all(bool $unserialize = true)

Get all of the cached values and their expiration times.

mixed
get(string $key)

Retrieve an item 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|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.

bool
supportsFlushingLocks()

Determine if the store can currently flush locks.

bool
flushLocks()

Remove all locks from the store.

string
getPrefix()

Get the cache key prefix.

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
hasSeparateLockStore()

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

array|null
getLockRecord(string $name)

Get the lock record for the given name.

void
putLockRecord(string $name, array $record)

Store the lock record for the given name.

void
forgetLockRecord(string $name)

Remove the lock record for the given name.

void
clearLockRecords()

Remove all lock records.

array|null
getCacheItem(string $key)

Get the cached item for the given key.

void
putCacheItem(string $key, array $item)

Store the cached item for the given key.

bool
forgetCacheItem(string $key)

Remove the cached item for the given key.

void
clearCacheItems()

Remove all cached items.

array
getCacheItems()

Get all cached items.

float
calculateExpiration(int $seconds)

Get the expiration time of the key.

float
toTimestamp(int $seconds)

Get the UNIX timestamp, with milliseconds, for the given number of seconds in the future.

mixed
unserialize(string $value)

Unserialize the given value.

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

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

in InteractsWithTime at line 41
protected DateTimeInterface|int parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 57
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

in InteractsWithTime at line 65
protected string runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float|null $endTime

Return Value

string

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

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 38
__construct(bool $serializesValues = false, array|bool|null $serializableClasses = null, SerializableClassPolicy|null $serializableClassPolicy = null)

Create a new array-family store.

Parameters

bool $serializesValues
array|bool|null $serializableClasses
SerializableClassPolicy|null $serializableClassPolicy

at line 53
array all(bool $unserialize = true)

Get all of the cached values and their expiration times.

Parameters

bool $unserialize

Return Value

array

at line 74
mixed get(string $key)

Retrieve an item from the cache by key.

Parameters

string $key

Return Value

mixed

at line 96
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 109
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 131
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 139
bool forever(string $key, mixed $value)

Store an item in the cache indefinitely.

Parameters

string $key
mixed $value

Return Value

bool

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

Adjust the expiration time of a cached item.

Parameters

string $key
int $seconds

Return Value

bool

at line 164
bool forget(string $key)

Remove an item from the cache.

Parameters

string $key

Return Value

bool

at line 172
bool flush()

Remove all items from the cache.

Return Value

bool

at line 182
bool supportsFlushingLocks()

Determine if the store can currently flush locks.

Return Value

bool

at line 192
bool flushLocks()

Remove all locks from the store.

Return Value

bool

Exceptions

RuntimeException

at line 206
string getPrefix()

Get the cache key prefix.

Return Value

string

at line 214
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 222
Lock restoreLock(string $name, string $owner)

Restore a lock instance using the owner identifier.

Parameters

string $name
string $owner

Return Value

Lock

at line 230
bool hasSeparateLockStore()

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

Return Value

bool

at line 240
abstract array|null getLockRecord(string $name)

Get the lock record for the given name.

Parameters

string $name

Return Value

array|null

at line 247
abstract void putLockRecord(string $name, array $record)

Store the lock record for the given name.

Parameters

string $name
array $record

Return Value

void

at line 252
abstract void forgetLockRecord(string $name)

Remove the lock record for the given name.

Parameters

string $name

Return Value

void

at line 257
abstract void clearLockRecords()

Remove all lock records.

Return Value

void

at line 264
abstract protected array|null getCacheItem(string $key)

Get the cached item for the given key.

Parameters

string $key

Return Value

array|null

at line 271
abstract protected void putCacheItem(string $key, array $item)

Store the cached item for the given key.

Parameters

string $key
array $item

Return Value

void

at line 276
abstract protected bool forgetCacheItem(string $key)

Remove the cached item for the given key.

Parameters

string $key

Return Value

bool

at line 281
abstract protected void clearCacheItems()

Remove all cached items.

Return Value

void

at line 288
abstract protected array getCacheItems()

Get all cached items.

Return Value

array

at line 293
protected float calculateExpiration(int $seconds)

Get the expiration time of the key.

Parameters

int $seconds

Return Value

float

at line 301
protected float toTimestamp(int $seconds)

Get the UNIX timestamp, with milliseconds, for the given number of seconds in the future.

Parameters

int $seconds

Return Value

float

at line 309
protected mixed unserialize(string $value)

Unserialize the given value.

Parameters

string $value

Return Value

mixed