mirror of
https://github.com/fluencelabs/redis
synced 2025-03-16 15:40:49 +00:00
DEBUG POPULATE two args form implemented.
The old DEBUG POPULATE form for automatic creation of test keys is: DEBUG POPULATE <count> Now an additional form is available: DEBUG POPULATE <count> <prefix> When prefix is not specified, it defaults to "key", so the keys are named incrementally from key:0 to key:<count-1>. Otherwise the specified prefix is used instead of "key". The command is useful in order to populate different Redis instances with key names guaranteed to don't collide. There are other debugging uses, for example it is possible to add additional N keys using a count of N and a random prefix at every call.
This commit is contained in:
parent
35a8302b7c
commit
d4222e6bee
@ -325,7 +325,8 @@ void debugCommand(redisClient *c) {
|
||||
(long long) sdslen(val->ptr),
|
||||
(long long) sdsavail(val->ptr));
|
||||
}
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"populate") && c->argc == 3) {
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"populate") &&
|
||||
(c->argc == 3 || c->argc == 4)) {
|
||||
long keys, j;
|
||||
robj *key, *val;
|
||||
char buf[128];
|
||||
@ -334,7 +335,8 @@ void debugCommand(redisClient *c) {
|
||||
return;
|
||||
dictExpand(c->db->dict,keys);
|
||||
for (j = 0; j < keys; j++) {
|
||||
snprintf(buf,sizeof(buf),"key:%lu",j);
|
||||
snprintf(buf,sizeof(buf),"%s:%lu",
|
||||
(c->argc == 3) ? "key" : c->argv[3]->ptr, j);
|
||||
key = createStringObject(buf,strlen(buf));
|
||||
if (lookupKeyRead(c->db,key) != NULL) {
|
||||
decrRefCount(key);
|
||||
|
Loading…
x
Reference in New Issue
Block a user