A
A
Anton B2014-11-20 13:29:06
PHP
Anton B, 2014-11-20 13:29:06

Redis, mset() + TTL possible?

Good afternoon.
Redis server v2.8
Redis client PhpRedis built from source I switched
to Redis with Memcached, using it as a layer in front of the database.
Very upset by the lack of the ability to set TTL in mSet(), hMSet().
Can you please suggest any solution?
DECISION

$trans = $redis->multi();

foreach ($items as $k => $v)
    $trans->setex($k, 100, $v);

$trans->exec();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@mgyk, 2014-11-20
@bigton

You can wrap everything in a transaction and set one value at a time

MULTI
SETEX key1 10 'value1'
SETEX key2 10 'value2'
EXEC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question