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
dc4be23e
Commit
dc4be23e
authored
Apr 21, 2010
by
antirez
Browse files
binary safe keys ready implementation of RANDOMKEYS
parent
24df7698
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
dc4be23e
...
@@ -4234,18 +4234,25 @@ static void selectCommand(redisClient *c) {
...
@@ -4234,18 +4234,25 @@ static void selectCommand(redisClient *c) {
static
void
randomkeyCommand
(
redisClient
*
c
)
{
static
void
randomkeyCommand
(
redisClient
*
c
)
{
dictEntry
*
de
;
dictEntry
*
de
;
robj
*
key
;
while
(
1
)
{
while
(
1
)
{
de
=
dictGetRandomKey
(
c
->
db
->
dict
);
de
=
dictGetRandomKey
(
c
->
db
->
dict
);
if
(
!
de
||
expireIfNeeded
(
c
->
db
,
dictGetEntryKey
(
de
))
==
0
)
break
;
if
(
!
de
||
expireIfNeeded
(
c
->
db
,
dictGetEntryKey
(
de
))
==
0
)
break
;
}
}
if
(
de
==
NULL
)
{
if
(
de
==
NULL
)
{
addReply
(
c
,
shared
.
plus
);
addReply
(
c
,
shared
.
nullbulk
);
addReply
(
c
,
shared
.
crlf
);
return
;
}
key
=
dictGetEntryKey
(
de
);
if
(
server
.
vm_enabled
)
{
key
=
dupStringObject
(
key
);
addReplyBulk
(
c
,
key
);
decrRefCount
(
key
);
}
else
{
}
else
{
addReply
(
c
,
shared
.
plus
);
addReplyBulk
(
c
,
key
);
addReply
(
c
,
dictGetEntryKey
(
de
));
addReply
(
c
,
shared
.
crlf
);
}
}
}
}
...
...
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