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
39685501
Commit
39685501
authored
Sep 24, 2018
by
antirez
Browse files
Modules: dictionary API work in progress #4: reseek API.
parent
14b2f7b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
39685501
...
...
@@ -4443,17 +4443,36 @@ RedisModuleDictIter *RM_DictIteratorStartStr(RedisModuleDict *d, const char *op,
return
RM_DictIteratorStart
(
d
,
op
,
key
->
ptr
,
sdslen
(
key
->
ptr
));
}
/* TODO
/* Release the iterator created with RedisModule_DictIteratorStart(). This call
* is mandatory otherwise a memory leak is introduced in the module. */
void
RM_DictIteratorStop
(
RedisModuleDictIter
*
di
)
{
raxStop
(
&
di
->
ri
);
zfree
(
di
);
}
/* After its creation with RedisModule_DictIteratorStart(), it is possible to
* change the currently selected element of the iterator by using this
* API call. The result based on the operator and key is exactly like
* the function RedisModule_DictIteratorStart(), however in this case the
* return value is just REDISMODULE_OK in case the seeked element was found,
* or REDISMODULE_ERR in case it was not possible to seek the specified
* element. It is possible to reseek an iterator as many times as you want. */
int
RM_DictIteratorReseek
(
RedisModuleDictIter
*
di
,
const
char
*
op
,
void
*
key
,
size_t
keylen
)
{
return
raxSeek
(
&
di
->
ri
,
op
,
key
,
keylen
);
}
RM_DictIteratorStart();
RM_DictIteratorStartStr();
RM_DictIteratorReseek();
RM_DictIteratorReseekStr();
/* Like RedisModule_DictIteratorReseek() but takes the key as as a
* RedisModuleString. */
int
RM_DictIteratorReseekStr
(
RedisModuleDictIter
*
di
,
const
char
*
op
,
RedisModuleString
*
key
)
{
return
RM_DictIteratorReseek
(
di
,
op
,
key
->
ptr
,
sdslen
(
key
->
ptr
));
}
/* TODO
RM_DictNext();
RM_DictPrev();
RM_DictNextStr();
RM_DictPrevStr();
RM_DictIteratorStop();
Change the string API to make the context optional.
*/
/* --------------------------------------------------------------------------
...
...
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