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
8fc85a12
Commit
8fc85a12
authored
Oct 31, 2013
by
antirez
Browse files
scanGenericCommand() refactoring and handling of integer encoded elements.
This commit fixes issue #1354.
parent
e6bb738b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
8fc85a12
...
@@ -480,15 +480,28 @@ void scanGenericCommand(redisClient *c, robj *o) {
...
@@ -480,15 +480,28 @@ void scanGenericCommand(redisClient *c, robj *o) {
while
(
node
)
{
while
(
node
)
{
robj
*
kobj
=
listNodeValue
(
node
);
robj
*
kobj
=
listNodeValue
(
node
);
nextnode
=
listNextNode
(
node
);
nextnode
=
listNextNode
(
node
);
int
filter
=
0
;
/* Filter element if it does not match the pattern. */
if
(
!
filter
&&
!
patnoop
)
{
if
(
sdsEncodedObject
(
kobj
))
{
if
(
!
stringmatchlen
(
pat
,
patlen
,
kobj
->
ptr
,
sdslen
(
kobj
->
ptr
),
0
))
filter
=
1
;
}
else
{
char
buf
[
REDIS_LONGSTR_SIZE
];
int
len
;
redisAssert
(
kobj
->
encoding
==
REDIS_ENCODING_INT
);
len
=
ll2string
(
buf
,
sizeof
(
buf
),(
long
)
kobj
->
ptr
);
if
(
!
stringmatchlen
(
pat
,
patlen
,
buf
,
len
,
0
))
filter
=
1
;
}
}
/* Keep key iff pattern matches and, if we are iterating the key
/* Filter element if it is an expired key. */
* space, check that the key hasn't expired. */
if
(
!
filter
&&
o
==
NULL
&&
expireIfNeeded
(
c
->
db
,
kobj
))
filter
=
1
;
if
((
patnoop
||
stringmatchlen
(
pat
,
patlen
,
kobj
->
ptr
,
sdslen
(
kobj
->
ptr
),
0
))
&&
/* Remove the element and its associted value if needed. */
(
o
!=
NULL
||
expireIfNeeded
(
c
->
db
,
kobj
)
==
0
))
if
(
filter
)
{
{
/* Keep */
}
else
{
decrRefCount
(
kobj
);
decrRefCount
(
kobj
);
listDelNode
(
keys
,
node
);
listDelNode
(
keys
,
node
);
/* Also remove the value for hashes and sorted sets. */
/* Also remove the value for hashes and sorted sets. */
...
...
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