}
/* Delete a key, value, and associated expiration entry if any, from the DB */
-int dbDelete(redisDb *db, robj *key) {
+int dbDeleteSoft(redisDb *db, robj *key) {
/* Deleting an entry from the expires dict will not free the sds of
* the key, because it is shared with the main dictionary. */
if (dictSize(db->expires) > 0) dictDelete(db->expires,key->ptr);
}
}
+/* Delete a key, value, and associated expiration entry if any, even archived */
+int dbDelete(redisDb *db, robj *key) {
+ purge(key);
+ return dbDeleteSoft(db, key);
+}
+
long long emptyDb() {
int j;
long long removed = 0;
sdsfree(sval);
return NULL;
}
+
+void purge(robj *key) {
+ if (server.mdb_state == REDIS_MDB_OFF)
+ return;
+
+ int ret;
+
+ MDB_val kval;
+ kval.mv_data = key->ptr;
+ kval.mv_size = sdslen((sds)key->ptr);
+
+ MDB_txn *txn;
+ ret = mdb_txn_begin(env, NULL, 0, &txn);
+ if (ret != 0)
+ return;
+
+ ret = mdb_del(txn, dbi, &kval, NULL);
+ if (ret != 0) {
+ mdb_txn_abort(txn);
+ return;
+ }
+
+ mdb_txn_commit(txn);
+}
* AOF and Output buffer memory will be freed eventually so
* we only care about memory used by the key space. */
delta = (long long) zmalloc_used_memory();
- dbDelete(db,keyobj);
+ dbDeleteSoft(db,keyobj);
delta -= (long long) zmalloc_used_memory();
mem_freed += delta;
server.stat_evictedkeys++;
void setKey(redisDb *db, robj *key, robj *val);
int dbExists(redisDb *db, robj *key);
robj *dbRandomKey(redisDb *db);
+int dbDeleteSoft(redisDb *db, robj *key);
int dbDelete(redisDb *db, robj *key);
long long emptyDb();
int selectDb(redisClient *c, int id);
int startKeyArchive(void);
robj *recover(redisDb *db, robj *key);
int archive(redisDb *db, robj *key);
+void purge(robj *key);
/* API to get key arguments from commands */
#define REDIS_GETKEYS_ALL 0