mirror of
https://github.com/fluencelabs/redis
synced 2025-03-27 21:01:04 +00:00
Cluster: fix case of slotToKey...() functions.
This commit is contained in:
parent
d04770988d
commit
392e0fa7eb
20
src/db.c
20
src/db.c
@ -32,9 +32,9 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
void SlotToKeyAdd(robj *key);
|
void slotToKeyAdd(robj *key);
|
||||||
void SlotToKeyDel(robj *key);
|
void slotToKeyDel(robj *key);
|
||||||
void SlotToKeyFlush(void);
|
void slotToKeyFlush(void);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
* C-level DB API
|
* C-level DB API
|
||||||
@ -94,7 +94,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
|
|||||||
int retval = dictAdd(db->dict, copy, val);
|
int retval = dictAdd(db->dict, copy, val);
|
||||||
|
|
||||||
redisAssertWithInfo(NULL,key,retval == REDIS_OK);
|
redisAssertWithInfo(NULL,key,retval == REDIS_OK);
|
||||||
if (server.cluster_enabled) SlotToKeyAdd(key);
|
if (server.cluster_enabled) slotToKeyAdd(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overwrite an existing key with a new value. Incrementing the reference
|
/* Overwrite an existing key with a new value. Incrementing the reference
|
||||||
@ -162,7 +162,7 @@ int dbDelete(redisDb *db, robj *key) {
|
|||||||
* the key, because it is shared with the main dictionary. */
|
* the key, because it is shared with the main dictionary. */
|
||||||
if (dictSize(db->expires) > 0) dictDelete(db->expires,key->ptr);
|
if (dictSize(db->expires) > 0) dictDelete(db->expires,key->ptr);
|
||||||
if (dictDelete(db->dict,key->ptr) == DICT_OK) {
|
if (dictDelete(db->dict,key->ptr) == DICT_OK) {
|
||||||
if (server.cluster_enabled) SlotToKeyDel(key);
|
if (server.cluster_enabled) slotToKeyDel(key);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -214,14 +214,14 @@ void flushdbCommand(redisClient *c) {
|
|||||||
signalFlushedDb(c->db->id);
|
signalFlushedDb(c->db->id);
|
||||||
dictEmpty(c->db->dict);
|
dictEmpty(c->db->dict);
|
||||||
dictEmpty(c->db->expires);
|
dictEmpty(c->db->expires);
|
||||||
if (server.cluster_enabled) SlotToKeyFlush();
|
if (server.cluster_enabled) slotToKeyFlush();
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flushallCommand(redisClient *c) {
|
void flushallCommand(redisClient *c) {
|
||||||
signalFlushedDb(-1);
|
signalFlushedDb(-1);
|
||||||
server.dirty += emptyDb();
|
server.dirty += emptyDb();
|
||||||
if (server.cluster_enabled) SlotToKeyFlush();
|
if (server.cluster_enabled) slotToKeyFlush();
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
if (server.rdb_child_pid != -1) {
|
if (server.rdb_child_pid != -1) {
|
||||||
kill(server.rdb_child_pid,SIGUSR1);
|
kill(server.rdb_child_pid,SIGUSR1);
|
||||||
@ -745,20 +745,20 @@ int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *num
|
|||||||
/* Slot to Key API. This is used by Redis Cluster in order to obtain in
|
/* Slot to Key API. This is used by Redis Cluster in order to obtain in
|
||||||
* a fast way a key that belongs to a specified hash slot. This is useful
|
* a fast way a key that belongs to a specified hash slot. This is useful
|
||||||
* while rehashing the cluster. */
|
* while rehashing the cluster. */
|
||||||
void SlotToKeyAdd(robj *key) {
|
void slotToKeyAdd(robj *key) {
|
||||||
unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
|
unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
|
||||||
|
|
||||||
zslInsert(server.cluster->slots_to_keys,hashslot,key);
|
zslInsert(server.cluster->slots_to_keys,hashslot,key);
|
||||||
incrRefCount(key);
|
incrRefCount(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotToKeyDel(robj *key) {
|
void slotToKeyDel(robj *key) {
|
||||||
unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
|
unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
|
||||||
|
|
||||||
zslDelete(server.cluster->slots_to_keys,hashslot,key);
|
zslDelete(server.cluster->slots_to_keys,hashslot,key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotToKeyFlush(void) {
|
void slotToKeyFlush(void) {
|
||||||
zslFree(server.cluster->slots_to_keys);
|
zslFree(server.cluster->slots_to_keys);
|
||||||
server.cluster->slots_to_keys = zslCreate();
|
server.cluster->slots_to_keys = zslCreate();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user