class Forever

Store an item in the cache indefinitely with tags support.

Stores the cache key and tag hash fields WITHOUT expiration (TTL = -1). Items must be manually deleted or flushed via tags.

Optimization: Uses Lua script to perform set, tag cleanup (remove from old), and tag addition (add to new) in a single network round trip (1 RTT).

Methods

__construct(StoreContext $context, Serialization $serialization)

Create a new forever with tags operation instance.

bool
execute(string $key, mixed $value, array $tags)

Execute the forever operation.

string
storeForeverWithTagsScript()

Get the Lua script for storing a value forever with tag tracking.

Details

at line 25
__construct(StoreContext $context, Serialization $serialization)

Create a new forever with tags operation instance.

Parameters

StoreContext $context
Serialization $serialization

at line 39
bool execute(string $key, mixed $value, array $tags)

Execute the forever operation.

Parameters

string $key

The cache key (without prefix)

mixed $value

The value to store (will be serialized)

array $tags

Array of tag names (will be cast to strings)

Return Value

bool

True if successful, false on failure

at line 155
protected string storeForeverWithTagsScript()

Get the Lua script for storing a value forever with tag tracking.

KEYS[1] - The cache key (prefixed) KEYS[2] - The reverse index key (tracks which tags this key belongs to) ARGV[1] - Serialized value ARGV[2] - Tag prefix for building tag hash keys ARGV[3] - Tag registry key ARGV[4] - Raw key (without prefix, for hash field name) ARGV[5] - Tag hash suffix (":entries") ARGV[6...] - Tag names

Return Value

string