class PutMany

Store multiple items in the cache (non-tagged).

Optimizes Laravel's default putMany() by using a Lua script in standard mode, reducing the number of commands Redis needs to parse.

Performance:

  • Standard mode: Single Lua script execution with evalSha caching
  • Cluster mode: Sequential SETEX commands over one held connection

Methods

__construct(StoreContext $context, Serialization $serialization)

Create a new put many operation instance.

bool
execute(array $values, int $seconds)

Execute the putMany operation.

string
setMultipleKeysScript()

Get the Lua script for setting multiple keys with the same TTL.

Details

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

Create a new put many operation instance.

Parameters

StoreContext $context
Serialization $serialization

at line 39
bool execute(array $values, int $seconds)

Execute the putMany operation.

Parameters

array $values

Array of key => value pairs

int $seconds

TTL in seconds

Return Value

bool

True if successful, false on failure

at line 118
protected string setMultipleKeysScript()

Get the Lua script for setting multiple keys with the same TTL.

KEYS[1..N] - The cache keys to set ARGV[1] - TTL in seconds ARGV[2..N+1] - Serialized values (matching order of KEYS)

Return Value

string