summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-12-18 11:58:02 +0100
committerantirez <antirez@gmail.com>2019-12-18 11:58:02 +0100
commit5b9d3ac6c6932b292c8895af8562c4df3c00464b (patch)
tree581447cc8efcf9e65cc67401bc1936c0b64b43a7
parent9d1baa070521f648e836eb741a050a8897d48129 (diff)
downloadredis-5b9d3ac6c6932b292c8895af8562c4df3c00464b.tar.gz
Avoid changing setKey() API after #6679 fix.
-rw-r--r--src/bitops.c2
-rw-r--r--src/db.c12
-rw-r--r--src/geo.c2
-rw-r--r--src/module.c6
-rw-r--r--src/server.h3
-rw-r--r--src/sort.c2
-rw-r--r--src/t_string.c6
7 files changed, 21 insertions, 12 deletions
diff --git a/src/bitops.c b/src/bitops.c
index dcd1f27a5..ee1ce0460 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -754,7 +754,7 @@ void bitopCommand(client *c) {
/* Store the computed value into the target key */
if (maxlen) {
o = createObject(OBJ_STRING,res);
- setKey(c->db,targetkey,o,0);
+ setKey(c->db,targetkey,o);
notifyKeyspaceEvent(NOTIFY_STRING,"set",targetkey,c->db->id);
decrRefCount(o);
} else if (dbDelete(c->db,targetkey)) {
diff --git a/src/db.c b/src/db.c
index 17834f37f..32bb35652 100644
--- a/src/db.c
+++ b/src/db.c
@@ -216,10 +216,11 @@ void dbOverwrite(redisDb *db, robj *key, robj *val) {
*
* 1) The ref count of the value object is incremented.
* 2) clients WATCHing for the destination key notified.
- * 3) The expire time of the key is reset (the key is made persistent).
+ * 3) The expire time of the key is reset (the key is made persistent),
+ * unless 'keepttl' is true.
*
* All the new keys in the database should be created via this interface. */
-void setKey(redisDb *db, robj *key, robj *val, int keepttl) {
+void genericSetKey(redisDb *db, robj *key, robj *val, int keepttl) {
if (lookupKeyWrite(db,key) == NULL) {
dbAdd(db,key,val);
} else {
@@ -230,6 +231,13 @@ void setKey(redisDb *db, robj *key, robj *val, int keepttl) {
signalModifiedKey(db,key);
}
+/* Common case for genericSetKey() where the TTL is not retained. */
+void setKey(redisDb *db, robj *key, robj *val) {
+ genericSetKey(db,key,val,0);
+}
+
+/* Return true if the specified key exists in the specified database.
+ * LRU/LFU info is not updated in any way. */
int dbExists(redisDb *db, robj *key) {
return dictFind(db->dict,key->ptr) != NULL;
}
diff --git a/src/geo.c b/src/geo.c
index 5d969ad98..049335a4f 100644
--- a/src/geo.c
+++ b/src/geo.c
@@ -657,7 +657,7 @@ void georadiusGeneric(client *c, int flags) {
if (returned_items) {
zsetConvertToZiplistIfNeeded(zobj,maxelelen);
- setKey(c->db,storekey,zobj,0);
+ setKey(c->db,storekey,zobj);
decrRefCount(zobj);
notifyKeyspaceEvent(NOTIFY_ZSET,"georadiusstore",storekey,
c->db->id);
diff --git a/src/module.c b/src/module.c
index 3bfde5cd4..1fda29625 100644
--- a/src/module.c
+++ b/src/module.c
@@ -2107,7 +2107,7 @@ RedisModuleString *RM_RandomKey(RedisModuleCtx *ctx) {
int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) {
if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR;
RM_DeleteKey(key);
- setKey(key->db,key->key,str,0);
+ setKey(key->db,key->key,str);
key->value = str;
return REDISMODULE_OK;
}
@@ -2187,7 +2187,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) {
if (key->value == NULL) {
/* Empty key: create it with the new size. */
robj *o = createObject(OBJ_STRING,sdsnewlen(NULL, newlen));
- setKey(key->db,key->key,o,0);
+ setKey(key->db,key->key,o);
key->value = o;
decrRefCount(o);
} else {
@@ -3571,7 +3571,7 @@ int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) {
if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR;
RM_DeleteKey(key);
robj *o = createModuleObject(mt,value);
- setKey(key->db,key->key,o,0);
+ setKey(key->db,key->key,o);
decrRefCount(o);
key->value = o;
return REDISMODULE_OK;
diff --git a/src/server.h b/src/server.h
index 655ac4f12..d9f24a1f6 100644
--- a/src/server.h
+++ b/src/server.h
@@ -2025,7 +2025,8 @@ int objectSetLRUOrLFU(robj *val, long long lfu_freq, long long lru_idle,
#define LOOKUP_NOTOUCH (1<<0)
void dbAdd(redisDb *db, robj *key, robj *val);
void dbOverwrite(redisDb *db, robj *key, robj *val);
-void setKey(redisDb *db, robj *key, robj *val, int keepttl);
+void genericSetKey(redisDb *db, robj *key, robj *val, int keepttl);
+void setKey(redisDb *db, robj *key, robj *val);
int dbExists(redisDb *db, robj *key);
robj *dbRandomKey(redisDb *db);
int dbSyncDelete(redisDb *db, robj *key);
diff --git a/src/sort.c b/src/sort.c
index c8666d6f5..db26da158 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -570,7 +570,7 @@ void sortCommand(client *c) {
}
}
if (outputlen) {
- setKey(c->db,storekey,sobj,0);
+ setKey(c->db,storekey,sobj);
notifyKeyspaceEvent(NOTIFY_LIST,"sortstore",storekey,
c->db->id);
server.dirty += outputlen;
diff --git a/src/t_string.c b/src/t_string.c
index 4ceb02fe3..8ccd69eb9 100644
--- a/src/t_string.c
+++ b/src/t_string.c
@@ -84,7 +84,7 @@ void setGenericCommand(client *c, int flags, robj *key, robj *val, robj *expire,
addReply(c, abort_reply ? abort_reply : shared.null[c->resp]);
return;
}
- setKey(c->db,key,val,flags & OBJ_SET_KEEPTTL);
+ genericSetKey(c->db,key,val,flags & OBJ_SET_KEEPTTL);
server.dirty++;
if (expire) setExpire(c,c->db,key,mstime()+milliseconds);
notifyKeyspaceEvent(NOTIFY_STRING,"set",key,c->db->id);
@@ -183,7 +183,7 @@ void getCommand(client *c) {
void getsetCommand(client *c) {
if (getGenericCommand(c) == C_ERR) return;
c->argv[2] = tryObjectEncoding(c->argv[2]);
- setKey(c->db,c->argv[1],c->argv[2],0);
+ setKey(c->db,c->argv[1],c->argv[2]);
notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[1],c->db->id);
server.dirty++;
}
@@ -328,7 +328,7 @@ void msetGenericCommand(client *c, int nx) {
for (j = 1; j < c->argc; j += 2) {
c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);
- setKey(c->db,c->argv[j],c->argv[j+1],0);
+ setKey(c->db,c->argv[j],c->argv[j+1]);
notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id);
}
server.dirty += (c->argc-1)/2;