有没有可能出现这种情况:
一段 lua 在运行过程中, 用 ttl 命令检查了 key 的剩余存活时间, 然后准备做进一步操作, 结果这个时间中 key 过期被清理了?
一段 lua 在运行过程中, 用 ttl 命令检查了 key 的剩余存活时间, 然后准备做进一步操作, 结果这个时间中 key 过期被清理了?
1
fuxinya Sep 4, 2019 via Android
参见 https://grokbase.com/t/gg/redis-db/1281v06jyr/keys-that-expire-in-lua-scripts
Since a whole Lua script execution is a single client command, Redis will not actively expire keys while a Lua client script is being run. |
2
fuxinya Sep 4, 2019 via Android
but if the TTL runs out and the script attempts to
access the key, Redis will notice the key is expired and act as if the key does not exist. |
3
Lax Sep 4, 2019
那段 lua 太慢的话先把 ttl 续上几秒再执行。最好不要因为单条 lua 指令会 block 其它请求。
|