class Increment

Increment the value of an item in the cache with tags support.

Increments the numeric value and adds/updates tag entries. If the key doesn't exist, creates it with the increment value (no initial TTL).

Optimization: Uses Lua script to perform increment, TTL check, and tag updates in a single network round trip (1 RTT).

Methods

__construct(StoreContext $context)

Create a new increment with tags operation instance.

int|bool
execute(string $key, int $value, array $tags)

Execute the increment operation.

string
incrementWithTagsScript()

Get the Lua script for incrementing a value with tag tracking.

Details

at line 24
__construct(StoreContext $context)

Create a new increment with tags operation instance.

Parameters

StoreContext $context

at line 37
int|bool execute(string $key, int $value, array $tags)

Execute the increment operation.

Parameters

string $key

The cache key (without prefix)

int $value

The amount to increment by

array $tags

Array of tag names (will be cast to strings)

Return Value

int|bool

The new value after incrementing, or false on failure

at line 158
protected string incrementWithTagsScript()

Get the Lua script for incrementing a value with tag tracking.

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

Return Value

string