Method Signature
Parameters
string
required
The key of the sorted set
ScoreMember<TData> | ZAddCommandOptions
required
Either a score-member pair object or options object. If options are provided, at least one score-member pair must follow.ScoreMember object:
score(number): The score for the membermember(TData): The member value to add
ScoreMember<TData>[]
Additional score-member pairs to add to the sorted set
ZAddCommandOptions
boolean
Only add new elements. Don’t update existing elements. Mutually exclusive with
xx.boolean
Only update existing elements. Don’t add new elements. Mutually exclusive with
nx.boolean
Only update existing elements if the new score is greater than the current score. Mutually exclusive with
lt.boolean
Only update existing elements if the new score is less than the current score. Mutually exclusive with
gt.boolean
Modify the return value to be the number of elements changed (added or updated), instead of only newly added elements.
boolean
When this option is specified, ZADD acts like ZINCRBY. Only one score-member pair can be specified in this mode.
Response
number | null
The number of elements added to the sorted set (not including elements already existing for which the score was updated).When
ch option is used, returns the number of elements that were changed (added or updated).When incr option is used, returns the new score of the member (as a number), or null if the operation was not performed.