From 80bde9844b7a88650bfd047dc913cc1da444e49c Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 27 Sep 2018 11:43:48 +0200 Subject: [PATCH] Modules: Modules: dictionary API WIP #12: DictCompare API. --- src/module.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/module.c b/src/module.c index 8295bd9b7..9c3d45f4c 100644 --- a/src/module.c +++ b/src/module.c @@ -4586,6 +4586,14 @@ int RM_DictCompareC(RedisModuleDictIter *di, const char *op, void *key, size_t k return res ? REDISMODULE_OK : REDISMODULE_ERR; } +/* Like RedisModule_DictCompareC but gets the key to compare with the current + * iterator key as a RedisModuleString. */ +int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *key) { + if (raxEOF(&di->ri)) return REDISMODULE_ERR; + int res = raxCompare(&di->ri,op,key->ptr,sdslen(key->ptr)); + return res ? REDISMODULE_OK : REDISMODULE_ERR; +} + /* -------------------------------------------------------------------------- * Modules utility APIs * -------------------------------------------------------------------------- */