Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
59305dc7
Commit
59305dc7
authored
May 07, 2010
by
antirez
Browse files
DEBUG POPULATE command for fast creation of test databases
parent
a0e7e5f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
59305dc7
...
...
@@ -10079,6 +10079,25 @@ static void debugCommand(redisClient *c) {
}
else
{
addReply
(
c
,
shared
.
err
);
}
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"populate"
)
&&
c
->
argc
==
3
)
{
long
keys
,
j
;
robj
*
key
,
*
val
;
char
buf
[
128
];
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
keys
,
NULL
)
!=
REDIS_OK
)
return
;
for
(
j
=
0
;
j
<
keys
;
j
++
)
{
snprintf
(
buf
,
sizeof
(
buf
),
"key:%lu"
,
j
);
key
=
createStringObject
(
buf
,
strlen
(
buf
));
if
(
lookupKeyRead
(
c
->
db
,
key
)
!=
NULL
)
{
decrRefCount
(
key
);
continue
;
}
snprintf
(
buf
,
sizeof
(
buf
),
"value:%lu"
,
j
);
val
=
createStringObject
(
buf
,
strlen
(
buf
));
dictAdd
(
c
->
db
->
dict
,
key
,
val
);
}
addReply
(
c
,
shared
.
ok
);
}
else
{
addReplySds
(
c
,
sdsnew
(
"-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|SWAPIN <key>|SWAPOUT <key>|RELOAD]
\r\n
"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment