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
3ff82790
Commit
3ff82790
authored
Sep 25, 2018
by
antirez
Browse files
Modules: dictionary API WIP #9: iterator returning string object.
parent
fb1d5717
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
3ff82790
...
@@ -4544,12 +4544,29 @@ void *RM_DictPrevC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) {
...
@@ -4544,12 +4544,29 @@ void *RM_DictPrevC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) {
return di->ri.key;
return di->ri.key;
}
}
/* TODO
/* Like RedisModuleNextC(), but instead of returning an internally allocated
RM_DictNextC();
* buffer and key length, it returns directly a module string object allocated
RM_DictPrevC();
* in the specified context 'ctx' (that may be NULL exactly like for the main
RM_DictNext();
* API RedisModule_CreateString).
RM_DictPrev();
*
*/
* The returned string object should be deallocated after use, either manually
* or by using a context that has automatic memory management active. */
RedisModuleString *RM_DictNext(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) {
size_t keylen;
void *key = RM_DictNextC(di,&keylen,dataptr);
if (key == NULL) return NULL;
return RM_CreateString(ctx,key,keylen);
}
/* Like RedisModule_DictNext() but after returning the currently selected
* element in the iterator, it selects the previous element (laxicographically
* smaller) instead of the next one. */
RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) {
size_t keylen;
void *key = RM_DictPrevC(di,&keylen,dataptr);
if (key == NULL) return NULL;
return RM_CreateString(ctx,key,keylen);
}
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Modules utility APIs
* Modules utility APIs
...
...
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