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 59
__construct(SwooleTableState $state, float $memoryLimitBuffer, string $evictionPolicy, float $evictionProportion, SerializableClassPolicy $serializableClassPolicy = new SerializableClassPolicy())
Create a new Swoole store.
at line 72
mixed
get(string $key)
Retrieve an item from the cache by key.
at line 103
protected bool
hasLocalInterval(string $key)
Determine if the key is a local interval.
at line 112
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 120
bool
put(string $key, mixed $value, int $seconds)
Store an item in the cache for a given number of seconds.
at line 132
bool
putMany(array $values, int $seconds)
Store multiple items in the cache for a given number of seconds.
at line 146
bool
add(string $key, mixed $value, int $seconds)
Store an item in the cache if the key doesn't exist.
at line 172
bool|int
increment(string $key, int $value = 1)
Increment the value of an item in the cache.
at line 205
bool|int
decrement(string $key, int $value = 1)
Decrement the value of an item in the cache.
at line 213
bool
forever(string $key, mixed $value)
Store an item in the cache indefinitely.
at line 236
bool
touch(string $key, int $seconds)
Adjust the expiration time of a cached item.
at line 260
void
interval(string $key, Closure $resolver, int $seconds)
Register a cache key that should be refreshed at a given interval in seconds.
at line 312
void
refreshIntervalCaches()
Refresh all of the applicable interval caches.
at line 322
protected bool
intervalShouldBeRefreshed(array $metadata, float $now)
Determine if the given interval record should be refreshed.
at line 331
bool
forget(string $key)
Remove an item from the cache.
at line 344
bool
flush()
Remove all items from the cache.
at line 362
bool
supportsFlushingLocks()
Determine if the store can currently flush locks.
at line 372
bool
flushLocks()
Remove all locks from the store.
at line 392
Lock
lock(string $name, int $seconds = 0, string|null $owner = null)
Get a lock instance.
at line 400
Lock
restoreLock(string $name, string $owner)
Restore a lock instance using the owner identifier.
at line 408
bool
hasSeparateLockStore()
Determine if the lock store is separate from the cache store.
at line 416
bool
acquireLock(string $name, string $owner, int $seconds)
Attempt to acquire a lock.
at line 438
bool
releaseLock(string $name, string $owner)
Release a lock if it is owned by the given owner.
at line 464
string|null
getLockOwner(string $name)
Get the current lock owner.
at line 476
bool
refreshLock(string $name, string $owner, int $seconds)
Refresh a lock's TTL.
at line 496
float|null
getLockRemainingLifetime(string $name)
Get the remaining lock lifetime in seconds.
at line 510
void
forceReleaseLock(string $name)
Force a lock to release.
at line 520
protected bool
recordIsFalseOrExpired(array|false $record)
Determine if the record is missing or expired.
at line 528
string
getPrefix()
Get the cache key prefix.
at line 536
void
evictRecords()
Evict records.
at line 554
protected void
evictRecordsIfNeeded()
Evict records if the table is near its memory limit.
at line 566
protected float
getCurrentTimestamp()
Get the current UNIX timestamp, with microsecond.
at line 576
protected bool
memoryLimitIsReached()
Determine if the memory limit is reached.
at line 589
protected int
removeRecordsByEvictionPolicy()
Remove records by the configured eviction policy.
at line 613
protected int
removeRecordsByLRU()
Remove records by least recently used.
at line 621
protected int
removeRecordsByLFU()
Remove records by least frequently used.
at line 629
protected int
removeRecordsByTTL()
Remove records by TTL.
at line 637
protected int
handleRecordsEviction(string $column)
Handle records eviction.
at line 646
protected int
compare($left, $right)
No description