mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Modules: dictionary API WIP #9: iterator returning string object.
This commit is contained in:
parent
fb1d5717de
commit
3ff82790e1
29
src/module.c
29
src/module.c
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user