Merge branch 'unstable' of github.com:/antirez/redis into unstable
This commit is contained in:
commit
62fc7f4f24
@ -6708,7 +6708,7 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int64_t ll;
|
int64_t ll;
|
||||||
while(intsetGet(o->ptr,pos++,&ll)) {
|
while(intsetGet(o->ptr,pos++,&ll)) {
|
||||||
robj *field = createStringObjectFromLongLong(ll);
|
robj *field = createObject(OBJ_STRING,sdsfromlonglong(ll));
|
||||||
fn(key, field, NULL, privdata);
|
fn(key, field, NULL, privdata);
|
||||||
decrRefCount(field);
|
decrRefCount(field);
|
||||||
}
|
}
|
||||||
@ -6724,12 +6724,12 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc
|
|||||||
ziplistGet(p,&vstr,&vlen,&vll);
|
ziplistGet(p,&vstr,&vlen,&vll);
|
||||||
robj *field = (vstr != NULL) ?
|
robj *field = (vstr != NULL) ?
|
||||||
createStringObject((char*)vstr,vlen) :
|
createStringObject((char*)vstr,vlen) :
|
||||||
createStringObjectFromLongLong(vll);
|
createObject(OBJ_STRING,sdsfromlonglong(vll));
|
||||||
p = ziplistNext(o->ptr,p);
|
p = ziplistNext(o->ptr,p);
|
||||||
ziplistGet(p,&vstr,&vlen,&vll);
|
ziplistGet(p,&vstr,&vlen,&vll);
|
||||||
robj *value = (vstr != NULL) ?
|
robj *value = (vstr != NULL) ?
|
||||||
createStringObject((char*)vstr,vlen) :
|
createStringObject((char*)vstr,vlen) :
|
||||||
createStringObjectFromLongLong(vll);
|
createObject(OBJ_STRING,sdsfromlonglong(vll));
|
||||||
fn(key, field, value, privdata);
|
fn(key, field, value, privdata);
|
||||||
p = ziplistNext(o->ptr,p);
|
p = ziplistNext(o->ptr,p);
|
||||||
decrRefCount(field);
|
decrRefCount(field);
|
||||||
|
@ -55,11 +55,23 @@ void scan_key_callback(RedisModuleKey *key, RedisModuleString* field, RedisModul
|
|||||||
REDISMODULE_NOT_USED(key);
|
REDISMODULE_NOT_USED(key);
|
||||||
scan_key_pd* pd = privdata;
|
scan_key_pd* pd = privdata;
|
||||||
RedisModule_ReplyWithArray(pd->ctx, 2);
|
RedisModule_ReplyWithArray(pd->ctx, 2);
|
||||||
RedisModule_ReplyWithString(pd->ctx, field);
|
size_t fieldCStrLen;
|
||||||
if (value)
|
|
||||||
RedisModule_ReplyWithString(pd->ctx, value);
|
// The implementation of RedisModuleString is robj with lots of encodings.
|
||||||
else
|
// We want to make sure the robj that passes to this callback in
|
||||||
|
// String encoded, this is why we use RedisModule_StringPtrLen and
|
||||||
|
// RedisModule_ReplyWithStringBuffer instead of directly use
|
||||||
|
// RedisModule_ReplyWithString.
|
||||||
|
const char* fieldCStr = RedisModule_StringPtrLen(field, &fieldCStrLen);
|
||||||
|
RedisModule_ReplyWithStringBuffer(pd->ctx, fieldCStr, fieldCStrLen);
|
||||||
|
if(value){
|
||||||
|
size_t valueCStrLen;
|
||||||
|
const char* valueCStr = RedisModule_StringPtrLen(value, &valueCStrLen);
|
||||||
|
RedisModule_ReplyWithStringBuffer(pd->ctx, valueCStr, valueCStrLen);
|
||||||
|
} else {
|
||||||
RedisModule_ReplyWithNull(pd->ctx);
|
RedisModule_ReplyWithNull(pd->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
pd->nreplies++;
|
pd->nreplies++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ start_server {tags {"modules"}} {
|
|||||||
r hmset hh f1 v1 f2 v2
|
r hmset hh f1 v1 f2 v2
|
||||||
lsort [r scan.scan_key hh]
|
lsort [r scan.scan_key hh]
|
||||||
} {{f1 v1} {f2 v2}}
|
} {{f1 v1} {f2 v2}}
|
||||||
|
|
||||||
|
test {Module scan hash dict with int value} {
|
||||||
|
r hmset hh1 f1 1
|
||||||
|
lsort [r scan.scan_key hh1]
|
||||||
|
} {{f1 1}}
|
||||||
|
|
||||||
test {Module scan hash dict} {
|
test {Module scan hash dict} {
|
||||||
r config set hash-max-ziplist-entries 2
|
r config set hash-max-ziplist-entries 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user