Redis - 键消失 [英] Redis - keys disappear
问题描述
Redis 中的键是否可以无故消失?我正在向 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("*");
然后钥匙消失了.什么可以删除此密钥?我确定过期时间已成功设置,因为此命令的结果为 1.
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.
我使用的是 redis 2.6
I'm using redis 2.6
推荐答案
如果在那段时间你没有用 Redis 做任何其他事情,用 redis-cli 打开一个 MONITOR
会话,看看会发生什么开启 - 另一个进程可能正在删除您的密钥.
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.
或者,也许您的 RAM 不足,Redis 的驱逐策略配置为驱逐易失性密钥.
Alternatively, perhaps you're running low on RAM and Redis' eviction policy is configured to evict volatile keys.
这篇关于Redis - 键消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!