add a new SET option KEEPTTL that doesn't remove expire time

This commit is contained in:
zhaozhao.zz
2019-12-18 14:49:38 +08:00
parent b7c78b7651
commit 24044f3356
8 changed files with 38 additions and 18 deletions

View File

@ -219,14 +219,14 @@ void dbOverwrite(redisDb *db, robj *key, robj *val) {
* 3) The expire time of the key is reset (the key is made persistent).
*
* All the new keys in the database should be created via this interface. */
void setKey(redisDb *db, robj *key, robj *val) {
void setKey(redisDb *db, robj *key, robj *val, int keepttl) {
if (lookupKeyWrite(db,key) == NULL) {
dbAdd(db,key,val);
} else {
dbOverwrite(db,key,val);
}
incrRefCount(val);
removeExpire(db,key);
if (!keepttl) removeExpire(db,key);
signalModifiedKey(db,key);
}