diff options
Diffstat (limited to 'src/db.c')
-rw-r--r-- | src/db.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -188,6 +188,24 @@ void dbAdd(redisDb *db, robj *key, robj *val) { if (server.cluster_enabled) slotToKeyAdd(key->ptr); } +/* This is a special version of dbAdd() that is used only when loading + * keys from the RDB file: the key is passed as an SDS string that is + * retained by the function (and not freed by the caller). + * + * Moreover this function will not abort if the key is already busy, to + * give more control to the caller, nor will signal the key as ready + * since it is not useful in this context. + * + * The function returns 1 if the key was added to the database, taking + * ownership of the SDS string, otherwise 0 is returned, and is up to the + * caller to free the SDS string. */ +int dbAddRDBLoad(redisDb *db, sds key, robj *val) { + int retval = dictAdd(db->dict, key, val); + if (retval != DICT_OK) return 0; + if (server.cluster_enabled) slotToKeyAdd(key); + return 1; +} + /* Overwrite an existing key with a new value. Incrementing the reference * count of the new value is up to the caller. * This function does not modify the expire time of the existing key. |