diff --git a/src/db.c b/src/db.c index 71c03fbe449..89e9c64500c 100644 --- a/src/db.c +++ b/src/db.c @@ -102,7 +102,7 @@ robj *lookupKey(redisDb *db, robj *key, int flags) { * Don't do it if we have a saving child, as this will trigger * a copy on write madness. */ if (server.current_client && server.current_client->flags & CLIENT_NO_TOUCH && - server.current_client->cmd->proc != touchCommand) + server.executing_client->cmd->proc != touchCommand) flags |= LOOKUP_NOTOUCH; if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)){ if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) { diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl index f9885c023fd..a2156fa3bd6 100644 --- a/tests/unit/introspection-2.tcl +++ b/tests/unit/introspection-2.tcl @@ -51,6 +51,26 @@ start_server {tags {"introspection"}} { assert_morethan $newlru $oldlru } {} {needs:debug} + test {Operations in no-touch mode TOUCH alters the last access time of a key} { + r set foo bar + r client no-touch on + set oldlru [getlru foo] + after 1100 + r touch foo + set newlru [getlru foo] + assert_morethan $newlru $oldlru + } {} {needs:debug} + + test {Operations in no-touch mode TOUCH from script alters the last access time of a key} { + r set foo bar + r client no-touch on + set oldlru [getlru foo] + after 1100 + assert_equal {1} [r eval "return redis.call('touch', 'foo')" 0] + set newlru [getlru foo] + assert_morethan $newlru $oldlru + } {} {needs:debug} + test {TOUCH returns the number of existing keys specified} { r flushdb r set key1{t} 1