DatabaseStore
class DatabaseStore implements CanFlushLocks, LockProvider, Store
Traits
Constants
| DEFAULT_LOCK_TABLE |
|
Properties
| protected ConnectionResolverInterface | $resolver | The database connection resolver. |
|
| protected string|null | $connectionName | The connection name. |
|
| protected string|null | $lockConnectionName | The lock connection name. |
|
| protected string | $table | The name of the cache table. |
|
| protected string | $prefix | A string that should be prepended to keys. |
|
| protected string | $lockTable | The name of the cache locks table. |
|
| protected array | $lockLottery | An array representation of the lock lottery odds. |
|
| protected int | $defaultLockTimeoutInSeconds | The default number of seconds that a lock should be held. |
|
| protected array|bool|null | $serializableClasses | The classes that should be allowed during unserialization. |
|
| protected SerializableClassPolicy|null | $serializableClassPolicy | The shared serializable class policy. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Create a new database store.
Get a fresh connection from the pool.
Retrieve an item from the cache by key.
Retrieve multiple items from the cache by key.
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.
Increment or decrement an item in the cache.
Get the current system time.
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 an item from the cache if it is expired.
Remove multiple items from the cache.
Remove all expired items from the given set from the cache.
Remove all items from the cache.
Determine if the store can currently flush locks.
Remove all locks from the store.
Remove all expired entries from the cache.
Get the underlying database connection.
Set the connection name for the cache store.
Get the connection used to manage locks.
Specify the connection that should be used to manage locks.
Get the cache key prefix.
Set the cache key prefix.
Serialize the given value.
Unserialize the given value.
Determine if the lock store is separate from the cache store.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 47
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 82
__construct(ConnectionResolverInterface $resolver, string|null $connectionName, string $table, string $prefix = '', string $lockTable = self::DEFAULT_LOCK_TABLE, array $lockLottery = [2, 100], int $defaultLockTimeoutInSeconds = 86400, array|bool|null $serializableClasses = null, SerializableClassPolicy|null $serializableClassPolicy = null)
Create a new database store.
at line 107
protected ConnectionInterface
connection()
Get a fresh connection from the pool.
at line 115
mixed
get(string $key)
Retrieve an item from the cache by key.
at line 125
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 166
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 174
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 201
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 217
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 227
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 237
protected bool|int
incrementOrDecrement(string $key, int $value, Closure $callback)
Increment or decrement an item in the cache.
at line 279
protected int
getTime()
Get the current system time.
at line 287
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 295
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 312
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 320
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 333
bool
forget(string $key)
Remove an item from the cache.
at line 341
bool
forgetIfExpired(string $key)
Remove an item from the cache if it is expired.
at line 349
protected bool
forgetMany(array $keys)
Remove multiple items from the cache.
at line 362
protected bool
forgetManyIfExpired(array $keys, bool $prefixed = false)
Remove all expired items from the given set from the cache.
at line 381
bool
flush()
Remove all items from the cache.
at line 391
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 401
bool
flushLocks()
Remove all locks from the store.
at line 415
int
pruneExpired()
Remove all expired entries from the cache.
at line 425
protected Builder
table()
Get a query builder for the cache table.
at line 433
protected Builder
lockTable()
Get a query builder for the cache locks table.
at line 441
ConnectionInterface
getConnection()
Get the underlying database connection.
at line 454
DatabaseStore
setConnection(string $connectionName)
Set the connection name for the cache store.
Persists on the cached store for the worker lifetime; per-request use races across coroutines.
at line 465
ConnectionInterface
getLockConnection()
Get the connection used to manage locks.
at line 478
DatabaseStore
setLockConnection(string $connectionName)
Specify the connection that should be used to manage locks.
Persists on the cached store for the worker lifetime; per-request use races across coroutines.
at line 489
string
getPrefix()
Get the cache key prefix.
at line 500
void
setPrefix(string $prefix)
Set the cache key prefix.
Persists on the cached store for the worker lifetime; per-request use races across coroutines.
at line 509
protected string
serialize(mixed $value)
Serialize the given value.
at line 526
protected mixed
unserialize(string $value)
Unserialize the given value.
at line 549
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.