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
62fc7f4f
Commit
62fc7f4f
authored
Jun 16, 2020
by
antirez
Browse files
Merge branch 'unstable' of github.com:/antirez/redis into unstable
parents
78447993
6ce2ed87
Changes
3
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
62fc7f4f
...
@@ -6708,7 +6708,7 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc
...
@@ -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
=
create
StringObjectF
rom
L
ong
L
ong
(
ll
);
robj
*
field
=
create
Object
(
OBJ_STRING
,
sdsf
rom
l
ong
l
ong
(
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
...
@@ -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
)
:
create
StringObjectF
rom
L
ong
L
ong
(
vll
);
create
Object
(
OBJ_STRING
,
sdsf
rom
l
ong
l
ong
(
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
)
:
create
StringObjectF
rom
L
ong
L
ong
(
vll
);
create
Object
(
OBJ_STRING
,
sdsf
rom
l
ong
l
ong
(
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
);
...
...
tests/modules/scan.c
View file @
62fc7f4f
...
@@ -55,11 +55,23 @@ void scan_key_callback(RedisModuleKey *key, RedisModuleString* field, RedisModul
...
@@ -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
++
;
}
}
...
...
tests/unit/moduleapi/scan.tcl
View file @
62fc7f4f
...
@@ -17,6 +17,11 @@ start_server {tags {"modules"}} {
...
@@ -17,6 +17,11 @@ start_server {tags {"modules"}} {
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
r hmset hh f3 v3
r hmset hh f3 v3
...
...
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