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
01e0341a
Commit
01e0341a
authored
Sep 27, 2018
by
antirez
Browse files
Modules: Modules: dictionary API WIP #11: DictCompareC API.
parent
f9b3ce9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
01e0341a
...
@@ -4568,6 +4568,24 @@ RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, voi
...
@@ -4568,6 +4568,24 @@ RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, voi
return
RM_CreateString
(
ctx
,
key
,
keylen
);
return
RM_CreateString
(
ctx
,
key
,
keylen
);
}
}
/* Compare the element currently pointed by the iterator to the specified
* element given by key/keylen, according to the operator 'op' (the set of
* valid operators are the same valid for RedisModule_DictIteratorStart).
* If the comparision is successful the command returns REDISMODULE_OK
* otherwise REDISMODULE_ERR is returned.
*
* This is useful when we want to just emit a lexicographical range, so
* in the loop, as we iterate elements, we can also check if we are still
* on range.
*
* The function returne REDISMODULE_ERR if the iterator reached the
* end of elements condition as well. */
int
RM_DictCompareC
(
RedisModuleDictIter
*
di
,
const
char
*
op
,
void
*
key
,
size_t
keylen
)
{
if
(
raxEOF
(
&
di
->
ri
))
return
REDISMODULE_ERR
;
int
res
=
raxCompare
(
&
di
->
ri
,
op
,
key
,
keylen
);
return
res
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
}
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* 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