You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation:
Issue #60 called for improving the type safety of the options available for the `zadd` command, and MR !70 made some great headway, but attempted to cram too much into a single enum.
Modifications:
- Break the `RedisSortedSetAddOption.returnChangedCount` value into an additional boolean param
Result:
Using `zadd` should now be more straight forward, while being type safe.
/// - element: The element and its score to add to the sorted set.
104
102
/// - key: The key of the sorted set.
105
-
/// - options: A set of options defined by Redis for this command to execute under.
106
-
/// - Returns: `true` if the element was added or score was updated in the sorted set.
103
+
/// - option: An option for modifying the behavior of the command.
104
+
/// - returnChangedCount: `zadd` normally returns the number of new elements added to the set,
105
+
/// but setting this to `true` will instead have the command return the number of elements changed.
106
+
///
107
+
/// "Changed" in this context are new elements added, and elements that had their score updated.
108
+
/// - Returns: `true` if the element was added or score was updated in the sorted set, depending on the `option` and `returnChangedCount` settings set.
107
109
@inlinable
108
110
publicfunc zadd<Value:RESPValueConvertible>(
109
111
_ element:(element:Value, score:Double),
110
112
to key:String,
111
-
options:Set<RedisSortedSetAddOption>=[]
113
+
option:RedisSortedSetAddOption?=nil,
114
+
returnChangedCount:Bool=false
112
115
)->EventLoopFuture<Bool>{
113
-
returnzadd([element], to: key,options: options)
116
+
returnzadd([element], to: key,option: option, returnChangedCount: returnChangedCount)
0 commit comments