@@ -73,8 +73,41 @@ trait SortedSetsApi extends ApiSubset {
7373 def zincrby (key : Key , increment : Double , member : Value ): Result [Double ] =
7474 execute(new Zincrby (key, increment, member))
7575
76+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
77+ def zinter (key : Key , keys : Key * ): Result [Seq [Value ]] =
78+ zinter(key +:: keys)
79+
80+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
81+ def zinter (keys : Iterable [Key ], aggregation : OptArg [Aggregation ] = OptArg .Empty ): Result [Seq [Value ]] =
82+ execute(new Zinter (keys, Opt .Empty , aggregation.toOpt))
83+
84+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
85+ def zinterWeights (keyWeight : (Key , Double ), keysWeights : (Key , Double )* ): Result [Seq [Value ]] =
86+ zinterWeights(keyWeight +:: keysWeights)
87+
88+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
89+ def zinterWeights (keysWeights : Iterable [(Key , Double )], aggregation : OptArg [Aggregation ] = OptArg .Empty ): Result [Seq [Value ]] =
90+ execute(new Zinter (keysWeights.map(_._1), keysWeights.map(_._2).opt, aggregation.toOpt))
91+
92+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
93+ def zinterWithscores (key : Key , keys : Key * ): Result [Seq [(Value , Double )]] =
94+ zinterWithscores(key +:: keys)
95+
96+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
97+ def zinterWithscores (keys : Iterable [Key ], aggregation : OptArg [Aggregation ] = OptArg .Empty ): Result [Seq [(Value , Double )]] =
98+ execute(new ZinterWithscores (keys, Opt .Empty , aggregation.toOpt))
99+
100+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
101+ def zinterWeightsWithscores (keyWeight : (Key , Double ), keysWeights : (Key , Double )* ): Result [Seq [(Value , Double )]] =
102+ zinterWeightsWithscores(keyWeight +:: keysWeights)
103+
104+ /** Executes [[http://redis.io/commands/zinter ZINTER ]] */
105+ def zinterWeightsWithscores (keysWeights : Iterable [(Key , Double )], aggregation : OptArg [Aggregation ] = OptArg .Empty ): Result [Seq [(Value , Double )]] =
106+ execute(new ZinterWithscores (keysWeights.map(_._1), keysWeights.map(_._2).opt, aggregation.toOpt))
107+
76108 /** Executes [[http://redis.io/commands/zinterstore ZINTERSTORE ]] */
77- def zinterstore (destination : Key , key : Key , keys : Key * ): Result [Long ] = zinterstore(destination, key +:: keys)
109+ def zinterstore (destination : Key , key : Key , keys : Key * ): Result [Long ] =
110+ zinterstore(destination, key +:: keys)
78111
79112 /** Executes [[http://redis.io/commands/zinterstore ZINTERSTORE ]]
80113 * NOTE: `keys` MUST NOT be empty */
@@ -265,12 +298,24 @@ trait SortedSetsApi extends ApiSubset {
265298 val encoded : Encoded = encoder(" ZINCRBY" ).key(key).add(increment).data(member).result
266299 }
267300
301+ private final class Zinter (keys : Iterable [Key ], weights : Opt [Iterable [Double ]], aggregation : Opt [Aggregation ])
302+ extends RedisDataSeqCommand [Value ] with NodeCommand {
303+ val encoded : Encoded = encoder(" ZINTER" ).add(keys.size).keys(keys)
304+ .optAdd(" WEIGHTS" , weights).optAdd(" AGGREGATE" , aggregation).result
305+ }
306+
268307 private final class Zinterstore (destination : Key , keys : Iterable [Key ], weights : Opt [Iterable [Double ]], aggregation : Opt [Aggregation ])
269308 extends RedisLongCommand with NodeCommand {
270309 val encoded : Encoded = encoder(" ZINTERSTORE" ).key(destination).add(keys.size).keys(keys)
271310 .optAdd(" WEIGHTS" , weights).optAdd(" AGGREGATE" , aggregation).result
272311 }
273312
313+ private final class ZinterWithscores (keys : Iterable [Key ], weights : Opt [Iterable [Double ]], aggregation : Opt [Aggregation ])
314+ extends AbstractRedisCommand [Seq [(Value , Double )]](flatMultiBulkAsPairSeq(bulkAs[Value ], bulkAsDouble)) with NodeCommand {
315+ val encoded : Encoded = encoder(" ZINTER" ).add(keys.size).keys(keys)
316+ .optAdd(" WEIGHTS" , weights).optAdd(" AGGREGATE" , aggregation).add(" WITHSCORES" ).result
317+ }
318+
274319 private final class Zlexcount (key : Key , min : LexLimit [Value ], max : LexLimit [Value ])
275320 extends RedisLongCommand with NodeCommand {
276321 val encoded : Encoded = encoder(" ZLEXCOUNT" ).key(key).add(LexLimit .repr(min)).add(LexLimit .repr(max)).result
@@ -306,8 +351,8 @@ trait SortedSetsApi extends ApiSubset {
306351 }
307352
308353 private abstract class AbstractZrangebyscore [T ](cmd : String , decoder : ReplyDecoder [Seq [T ]])(
309- key : Key , firstLimit : ScoreLimit , secondLimit : ScoreLimit , withscores : Boolean , limit : Opt [Limit ])
310- extends AbstractRedisCommand [Seq [T ]](decoder) with NodeCommand {
354+ key : Key , firstLimit : ScoreLimit , secondLimit : ScoreLimit , withscores : Boolean , limit : Opt [Limit ]
355+ ) extends AbstractRedisCommand [Seq [T ]](decoder) with NodeCommand {
311356 val encoded : Encoded =
312357 encoder(cmd).key(key).add(firstLimit.repr).add(secondLimit.repr)
313358 .addFlag(" WITHSCORES" , withscores).optAdd(" LIMIT" , limit).result
0 commit comments