Add a new element into a sorted set, with the specified 'score'. * If the element already exists, the score is updated. * * A new sorted set is created at value if the key is an empty open key * setup for writing. * * Additional flags can be passed to the function via a pointer, the flags * are both used to receive input and to communicate state when the function * returns. 'flagsptr' can
| 2650 | * * 'score' double value is not a number (NaN). |
| 2651 | */ |
| 2652 | int RM_ZsetAdd(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) { |
| 2653 | int in_flags = 0, out_flags = 0; |
| 2654 | if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; |
| 2655 | if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; |
| 2656 | if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); |
| 2657 | if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); |
| 2658 | if (zsetAdd(key->value,score,ele->ptr,in_flags,&out_flags,NULL) == 0) { |
| 2659 | if (flagsptr) *flagsptr = 0; |
| 2660 | return REDISMODULE_ERR; |
| 2661 | } |
| 2662 | if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); |
| 2663 | return REDISMODULE_OK; |
| 2664 | } |
| 2665 | |
| 2666 | /* This function works exactly like RM_ZsetAdd(), but instead of setting |
| 2667 | * a new score, the score of the existing element is incremented, or if the |
nothing calls this directly
no test coverage detected