SwooleStore
class SwooleStore implements CanFlushLocks, LockProvider, Store
Constants
| EVICTION_POLICY_LRU |
|
| EVICTION_POLICY_LFU |
|
| EVICTION_POLICY_TTL |
|
| EVICTION_POLICY_NOEVICTION |
|
| protected USER_PREFIX |
|
| protected INTERVAL_PREFIX |
|
| protected INTERVAL_INDEX_PREFIX |
|
| protected INTERVAL_INDEX_SHARDS |
|
| protected INTERVAL_REFRESH_CLAIM_TIMEOUT |
|
| protected LOCK_PREFIX |
|
Properties
| protected SwooleTable | $table | ||
| protected array<string, true> | $intervals | Locally registered interval cache keys. |
Methods
Create a new Swoole store.
Retrieve an item from the cache by key.
Determine if the key is a local interval.
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.
Store an item in the cache indefinitely.
Adjust the expiration time of a cached item.
Refresh all of the applicable interval caches.
Determine if the given interval record should be refreshed.
Remove an item from the cache.
Remove all items from the cache.
Determine if the store can currently flush locks.
Remove all locks from the store.
Restore a lock instance using the owner identifier.
Determine if the lock store is separate from the cache store.
Attempt to acquire a lock.
Release a lock if it is owned by the given owner.
Get the current lock owner.
Refresh a lock's TTL.
Get the remaining lock lifetime in seconds.
Force a lock to release.
Determine if the record is missing or expired.
Get the cache key prefix.
Evict records.
Evict records if the table is near its memory limit.
Get the current UNIX timestamp, with microsecond.
Determine if the memory limit is reached.
Remove records by the configured eviction policy.
Remove records by least recently used.
Remove records by least frequently used.
Remove records by TTL.
Handle records eviction.
No description
Details
at line 58
__construct(SwooleTableState $state, float $memoryLimitBuffer, string $evictionPolicy, float $evictionProportion, SerializableClassPolicy $serializableClassPolicy = new SerializableClassPolicy())
Create a new Swoole store.
at line 71
mixed
get(string $key)
Retrieve an item from the cache by key.
at line 102
protected bool
hasLocalInterval(string $key)
Determine if the key is a local interval.
at line 111
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 119
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 131
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 145
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 171
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 204
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 212
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 235
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 259
void
interval(string $key, Closure $resolver, int $seconds)
Register a cache key that should be refreshed at a given interval in seconds.
at line 303
void
refreshIntervalCaches()
Refresh all of the applicable interval caches.
at line 313
protected bool
intervalShouldBeRefreshed(array $metadata, float $now)
Determine if the given interval record should be refreshed.
at line 322
bool
forget(string $key)
Remove an item from the cache.
at line 335
bool
flush()
Remove all items from the cache.
at line 353
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 363
bool
flushLocks()
Remove all locks from the store.
at line 383
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 391
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 399
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.
at line 407
bool
acquireLock(string $name, string $owner, int $seconds)
Attempt to acquire a lock.
at line 429
bool
releaseLock(string $name, string $owner)
Release a lock if it is owned by the given owner.
at line 455
string|null
getLockOwner(string $name)
Get the current lock owner.
at line 467
bool
refreshLock(string $name, string $owner, int $seconds)
Refresh a lock's TTL.
at line 487
float|null
getLockRemainingLifetime(string $name)
Get the remaining lock lifetime in seconds.
at line 501
void
forceReleaseLock(string $name)
Force a lock to release.
at line 511
protected bool
recordIsFalseOrExpired(array|false $record)
Determine if the record is missing or expired.
at line 519
string
getPrefix()
Get the cache key prefix.
at line 527
void
evictRecords()
Evict records.
at line 545
protected void
evictRecordsIfNeeded()
Evict records if the table is near its memory limit.
at line 557
protected float
getCurrentTimestamp()
Get the current UNIX timestamp, with microsecond.
at line 567
protected bool
memoryLimitIsReached()
Determine if the memory limit is reached.
at line 580
protected int
removeRecordsByEvictionPolicy()
Remove records by the configured eviction policy.
at line 604
protected int
removeRecordsByLRU()
Remove records by least recently used.
at line 612
protected int
removeRecordsByLFU()
Remove records by least frequently used.
at line 620
protected int
removeRecordsByTTL()
Remove records by TTL.
at line 628
protected int
handleRecordsEviction(string $column)
Handle records eviction.
at line 637
protected int
compare($left, $right)
No description