summaryrefslogtreecommitdiff
path: root/src/t_string.c
diff options
context:
space:
mode:
authorMingyi Kang <jerrykang026@gmail.com>2022-09-08 11:35:25 +0800
committerGitHub <noreply@github.com>2022-09-07 22:35:25 -0500
commite67d06ee6be9c93fe626ad19f11b2d572d58a0ba (patch)
treea63e0ce36fca3d6ddfe20f305bfcf356e08f7380 /src/t_string.c
parent89018ff6a78dd130f0d03914ce658e9f73010948 (diff)
downloadredis-e67d06ee6be9c93fe626ad19f11b2d572d58a0ba.tar.gz
Optimize setGenericCommand(): no need to remove the expiration entry when 'expire' is not NULL (#11244)
Diffstat (limited to 'src/t_string.c')
-rw-r--r--src/t_string.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/t_string.c b/src/t_string.c
index 9d7bc44fc..5d1612a20 100644
--- a/src/t_string.c
+++ b/src/t_string.c
@@ -99,7 +99,8 @@ void setGenericCommand(client *c, int flags, robj *key, robj *val, robj *expire,
return;
}
- setkey_flags |= (flags & OBJ_KEEPTTL) ? SETKEY_KEEPTTL : 0;
+ /* When expire is not NULL, we avoid deleting the TTL so it can be updated later instead of being deleted and then created again. */
+ setkey_flags |= ((flags & OBJ_KEEPTTL) || expire) ? SETKEY_KEEPTTL : 0;
setkey_flags |= found ? SETKEY_ALREADY_EXIST : SETKEY_DOESNT_EXIST;
setKey(c,c->db,key,val,setkey_flags);