Cluster: empty the internal sorted set mapping keys to slots on FLUSHDB/ALL.

This commit is contained in:
antirez 2013-02-22 10:15:32 +01:00
parent efe51dfff5
commit d04770988d

View File

@ -34,6 +34,7 @@
void SlotToKeyAdd(robj *key);
void SlotToKeyDel(robj *key);
void SlotToKeyFlush(void);
/*-----------------------------------------------------------------------------
* C-level DB API
@ -213,12 +214,14 @@ void flushdbCommand(redisClient *c) {
signalFlushedDb(c->db->id);
dictEmpty(c->db->dict);
dictEmpty(c->db->expires);
if (server.cluster_enabled) SlotToKeyFlush();
addReply(c,shared.ok);
}
void flushallCommand(redisClient *c) {
signalFlushedDb(-1);
server.dirty += emptyDb();
if (server.cluster_enabled) SlotToKeyFlush();
addReply(c,shared.ok);
if (server.rdb_child_pid != -1) {
kill(server.rdb_child_pid,SIGUSR1);
@ -755,6 +758,11 @@ void SlotToKeyDel(robj *key) {
zslDelete(server.cluster->slots_to_keys,hashslot,key);
}
void SlotToKeyFlush(void) {
zslFree(server.cluster->slots_to_keys);
server.cluster->slots_to_keys = zslCreate();
}
unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) {
zskiplistNode *n;
zrangespec range;