High level Set operation. This function can be used in order to set * a key, whatever it was existing or not, to a new object. * * 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), * unless 'keepttl' is true. * * All the new keys in the database should be cre
| 257 | * The client 'c' argument may be set to NULL if the operation is performed |
| 258 | * in a context where there is no clear client performing the operation. */ |
| 259 | void genericSetKey(client *c, redisDb *db, robj *key, robj *val, int keepttl, int signal) { |
| 260 | if (lookupKeyWrite(db,key) == NULL) { |
| 261 | dbAdd(db,key,val); |
| 262 | } else { |
| 263 | dbOverwrite(db,key,val); |
| 264 | } |
| 265 | incrRefCount(val); |
| 266 | if (!keepttl) removeExpire(db,key); |
| 267 | if (signal) signalModifiedKey(c,db,key); |
| 268 | } |
| 269 | |
| 270 | /* Common case for genericSetKey() where the TTL is not retained. */ |
| 271 | void setKey(client *c, redisDb *db, robj *key, robj *val) { |
no test coverage detected