Update PR #6537 patch to for generality.

After the thread in #6537 and thanks to the suggestions received, this
commit updates the original patch in order to:

1. Solve the problem of updating the time in multiple places by updating
it in call().
2. Avoid introducing a new field but use our cached time.

This required some minor refactoring to the function updating the time,
and the introduction of a new cached time in microseconds in order to
use less gettimeofday() calls.
This commit is contained in:
antirez
2019-11-05 10:14:34 +01:00
parent e542132b07
commit 824f5f0b7a
4 changed files with 34 additions and 19 deletions

View File

@ -1198,8 +1198,12 @@ int keyIsExpired(redisDb *db, robj *key) {
* blocked to when the Lua script started. This way a key can expire
* only the first time it is accessed and not in the middle of the
* script execution, making propagation to slaves / AOF consistent.
* See issue #1525 on Github for more information. */
mstime_t now = server.lua_caller ? server.lua_time_start : server.cmd_start_mstime;
* See issue #1525 on Github for more information.
*
* Outside the Lua script execution, we use the cached time server.mstime
* that is updated before commands executions in call(). */
mstime_t now = server.lua_caller ? server.lua_time_start :
server.mstime;
return now > when;
}