Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis - keys disappear

Tags:

redis

Is it possible to disappear keys in Redis without reason? I'm adding keys to redis:

Transaction transaction = jedis.multi();
transaction.incrBy(positionsQuantityKey, positionQuantity);
transaction.expire(positionsQuantityKey, 24 * 3600);
transaction.exec();

but after few minutes I ran command:

jedis.keys("*");

and the key disappeared. What could delete this key? I'm sure that expire time was succesfully set, because result of this command was 1.

I'm using redis 2.6

like image 391
Toma Avatar asked May 28 '15 15:05

Toma


People also ask

Does Redis delete keys?

Redis will drop the key and its associated data if the specified key exists in the data store. You can also use the DEL command to remove multiple keys in a single instance.

Do Redis keys expire?

Normally Redis keys are created without an associated time to live. The key will simply live forever, unless it is removed by the user in an explicit way, for instance using the DEL command.

Does Redis overwrite keys?

If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.

What does Redis return if key doesnt exist?

In applications that utilize redis a very common task that needs to be performed is checking to see if a key exists or not. Now technically you could just use the get command and if it returns an element then it means that the key exists and if it returns nil then it means that key did not exist.


1 Answers

If you're not doing anything else with Redis during that time, open a MONITOR session with redis-cli and look what goes on - another process could be deleting your key.

Alternatively, perhaps you're running low on RAM and Redis' eviction policy is configured to evict volatile keys.

like image 69
Itamar Haber Avatar answered Nov 16 '22 01:11

Itamar Haber