mirror of
https://github.com/fluencelabs/redis
synced 2025-04-13 20:56:03 +00:00
scanGenericCommand() refactoring and handling of integer encoded elements.
This commit fixes issue #1354.
This commit is contained in:
parent
e6bb738b87
commit
8fc85a1218
27
src/db.c
27
src/db.c
@ -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;
|
||||||
|
|
||||||
/* Keep key iff pattern matches and, if we are iterating the key
|
/* Filter element if it does not match the pattern. */
|
||||||
* space, check that the key hasn't expired. */
|
if (!filter && !patnoop) {
|
||||||
if ((patnoop ||
|
if (sdsEncodedObject(kobj)) {
|
||||||
stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0)) &&
|
if (!stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0))
|
||||||
(o != NULL || expireIfNeeded(c->db, kobj) == 0))
|
filter = 1;
|
||||||
{
|
|
||||||
/* Keep */
|
|
||||||
} else {
|
} 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Filter element if it is an expired key. */
|
||||||
|
if (!filter && o == NULL && expireIfNeeded(c->db, kobj)) filter = 1;
|
||||||
|
|
||||||
|
/* Remove the element and its associted value if needed. */
|
||||||
|
if (filter) {
|
||||||
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. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user