StoreContext
class StoreContext
Mode-aware context for Redis cache operations.
Constants
| MAX_EXPIRY |
The maximum expiry timestamp (Year 9999) for "forever" items. Used in the tag registry to represent items with no expiration. |
| TAG_FIELD_VALUE |
The value stored in tag hash fields. We only need to track membership, so we use a minimal placeholder value. |
Methods
Create a new store context instance.
Get the cache key prefix.
Get the connection name.
Get the tag mode.
Get the tag membership score for a cache lifetime.
Get the tag identifier (without cache prefix).
Get the full tag hash key for a given tag.
Get the tag hash suffix (for Lua scripts that build keys dynamically).
Get the SCAN pattern for finding all tag sorted sets.
Get the full reverse index key for a cache key.
Get the tag registry key (without OPT_PREFIX).
Execute callback with a held connection from the pool.
Check if the connection is a Redis Cluster.
Get the full tag prefix including OPT_PREFIX (for Lua scripts).
Get the full registry key including OPT_PREFIX (for Lua scripts).
Details
at line 35
__construct(Factory $redis, string $connectionName, string $prefix, TagMode $tagMode)
Create a new store context instance.
at line 47
string
prefix()
Get the cache key prefix.
at line 55
string
connectionName()
Get the connection name.
at line 63
TagMode
tagMode()
Get the tag mode.
at line 71
int
expirationScore(int $seconds)
Get the tag membership score for a cache lifetime.
at line 82
string
tagId(string $tag)
Get the tag identifier (without cache prefix).
Used by all mode for namespace computation (xxh128 of tag IDs in requested order). Format: "_any:tag:{tagName}:entries" or "_all:tag:{tagName}:entries"
at line 92
string
tagHashKey(string $tag)
Get the full tag hash key for a given tag.
Format: "{prefix}_any:tag:{tagName}:entries" or "{prefix}_all:tag:{tagName}:entries"
at line 100
string
tagHashSuffix()
Get the tag hash suffix (for Lua scripts that build keys dynamically).
at line 110
string
tagScanPattern()
Get the SCAN pattern for finding all tag sorted sets.
Format: "{prefix}_any:tag::entries" or "{prefix}_all:tag::entries"
at line 120
string
reverseIndexKey(string $key)
Get the full reverse index key for a cache key.
Format: "{prefix}{cacheKey}:_any:tags" or "{prefix}{cacheKey}:_all:tags"
at line 130
string
registryKey()
Get the tag registry key (without OPT_PREFIX).
Format: "{prefix}_any:tag:registry" or "{prefix}_all:tag:registry"
at line 146
mixed
withConnection(callable $callback, bool $transform = false)
Execute callback with a held connection from the pool.
Delegates to Redis::withConnection() for context awareness (respects active pipeline/multi connections). Cache operations use raw phpredis behavior unless they explicitly request Laravel-style transforms.
at line 156
bool
isCluster()
Check if the connection is a Redis Cluster.
at line 166
string
optPrefix(RedisConnection $connection)
Get the OPT_PREFIX value from the Redis client.
at line 177
string
fullTagPrefix(RedisConnection $connection)
Get the full tag prefix including OPT_PREFIX (for Lua scripts).
Format: "{optPrefix}{prefix}_any:tag:" or "{optPrefix}{prefix}_all:tag:"
at line 185
string
fullRegistryKey(RedisConnection $connection)
Get the full registry key including OPT_PREFIX (for Lua scripts).