This function works exactly like RM_ZsetAdd(), but instead of setting * a new score, the score of the existing element is incremented, or if the * element does not already exist, it is added assuming the old score was * zero. * * The input and output flags, and the return value, have the same exact * meaning, with the only difference that this function will return * REDISMODULE_ERR even whe
| 2765 | * with the new score of the element after the increment, if no error |
| 2766 | * is returned. */ |
| 2767 | int RM_ZsetIncrby(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) { |
| 2768 | int in_flags = 0, out_flags = 0; |
| 2769 | if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; |
| 2770 | if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; |
| 2771 | if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); |
| 2772 | if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); |
| 2773 | in_flags |= ZADD_IN_INCR; |
| 2774 | if (zsetAdd(key->value,score,szFromObj(ele),in_flags,&out_flags,newscore) == 0) { |
| 2775 | if (flagsptr) *flagsptr = 0; |
| 2776 | return REDISMODULE_ERR; |
| 2777 | } |
| 2778 | if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); |
| 2779 | return REDISMODULE_OK; |
| 2780 | } |
| 2781 | |
| 2782 | /* Remove the specified element from the sorted set. |
| 2783 | * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR |
nothing calls this directly
no test coverage detected