未验证 提交 fc43d270 编写于 作者: A Anatoly Sergeev 提交者: GitHub

add resp command in order to distinguish resp types (#763)

上级 f863f6c7
......@@ -31,7 +31,7 @@ final case class ClusterExecutor(
scope: Scope.Closeable
) extends RedisExecutor {
def execute(command: Chunk[RespValue.BulkString]): IO[RedisError, RespValue] = {
def execute(command: RespCommand): IO[RedisError, RespValue] = {
def execute(keySlot: Slot) =
for {
......@@ -58,7 +58,7 @@ final case class ClusterExecutor(
}
for {
key <- ZIO.attempt(command(1)).orElseFail(CusterKeyError)
key <- ZIO.attempt(command.args(1).value).orElseFail(CusterKeyError)
keySlot = Slot((key.asCRC16 % SlotsAmount).toLong)
result <- executeSafe(keySlot)
} yield result
......
......@@ -17,7 +17,7 @@
package zio.redis
import zio._
import zio.redis.Input.{StringInput, Varargs}
import zio.redis.Input.{CommandNameInput, Varargs}
import zio.schema.codec.BinaryCodec
final class RedisCommand[-In, +Out] private (
......@@ -34,8 +34,8 @@ final class RedisCommand[-In, +Out] private (
.flatMap[Any, Throwable, Out](out => ZIO.attempt(output.unsafeDecode(out)(codec)))
.refineToOrDie[RedisError]
private[redis] def resp(in: In): Chunk[RespValue.BulkString] =
Varargs(StringInput).encode(name.split(" "))(codec) ++ input.encode(in)(codec)
private[redis] def resp(in: In): RespCommand =
Varargs(CommandNameInput).encode(name.split(" "))(codec) ++ input.encode(in)(codec)
}
object RedisCommand {
......
......@@ -16,10 +16,10 @@
package zio.redis
import zio.{Chunk, IO, ZLayer}
import zio.{IO, ZLayer}
trait RedisExecutor {
def execute(command: Chunk[RespValue.BulkString]): IO[RedisError, RespValue]
def execute(command: RespCommand): IO[RedisError, RespValue]
}
object RedisExecutor {
......
/*
* Copyright 2021 John A. De Goes and the ZIO contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package zio.redis
import zio.Chunk
import zio.redis.RespValue.BulkString
import zio.schema.Schema
import zio.schema.codec.BinaryCodec
import java.nio.charset.StandardCharsets
sealed trait RespArgument {
def value: RespValue.BulkString
}
object RespArgument {
final case class Unknown(bytes: Chunk[Byte]) extends RespArgument {
lazy val value: BulkString = RespValue.BulkString(bytes)
}
object Unknown {
def apply(str: String): Unknown = Unknown(Chunk.fromArray(str.getBytes(StandardCharsets.UTF_8)))
def apply[A](data: A)(implicit codec: BinaryCodec, schema: Schema[A]): Unknown = Unknown(codec.encode(schema)(data))
}
final case class CommandName(str: String) extends RespArgument {
lazy val value: BulkString = RespValue.bulkString(str)
}
final case class Literal(str: String) extends RespArgument {
lazy val value: BulkString = RespValue.bulkString(str)
}
final case class Key(bytes: Chunk[Byte]) extends RespArgument {
lazy val value: BulkString = RespValue.BulkString(bytes)
}
object Key {
def apply[A](data: A)(implicit codec: BinaryCodec, schema: Schema[A]): Key = Key(codec.encode(schema)(data))
}
final case class Value(bytes: Chunk[Byte]) extends RespArgument {
lazy val value: BulkString = RespValue.BulkString(bytes)
}
object Value {
def apply[A](data: A)(implicit codec: BinaryCodec, schema: Schema[A]): Value = Value(codec.encode(schema)(data))
}
}
/*
* Copyright 2021 John A. De Goes and the ZIO contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package zio.redis
import zio.Chunk
final case class RespCommand(args: Chunk[RespArgument]) {
def ++(that: RespCommand): RespCommand = RespCommand(this.args ++ that.args)
def mapArguments(f: RespArgument => RespArgument): RespCommand = RespCommand(args.map(f(_)))
}
object RespCommand {
def empty: RespCommand = new RespCommand(Chunk.empty)
def apply(args: Chunk[RespArgument]): RespCommand = new RespCommand(args)
def apply(args: RespArgument*): RespCommand = new RespCommand(Chunk.fromIterable(args))
def apply(arg: RespArgument): RespCommand = new RespCommand(Chunk.single(arg))
}
......@@ -26,10 +26,10 @@ final class SingleNodeExecutor(
) extends RedisExecutor {
// TODO NodeExecutor doesn't throw connection errors, timeout errors, it is hanging forever
def execute(command: Chunk[RespValue.BulkString]): IO[RedisError, RespValue] =
def execute(command: RespCommand): IO[RedisError, RespValue] =
Promise
.make[RedisError, RespValue]
.flatMap(promise => reqQueue.offer(Request(command, promise)) *> promise.await)
.flatMap(promise => reqQueue.offer(Request(command.args.map(_.value), promise)) *> promise.await)
/**
* Opens a connection to the server and launches send and receive operations. All failures are retried by opening a
......
......@@ -58,7 +58,7 @@ trait Cluster extends RedisEnvironment {
*/
final def setSlotStable(slot: Slot): IO[RedisError, Unit] = {
val command =
RedisCommand(ClusterSetSlots, Tuple2(LongInput, ArbitraryInput[String]()), UnitOutput, codec, executor)
RedisCommand(ClusterSetSlots, Tuple2(LongInput, ArbitraryValueInput[String]()), UnitOutput, codec, executor)
command.run((slot.number, Stable.stringify))
}
......@@ -76,7 +76,7 @@ trait Cluster extends RedisEnvironment {
final def setSlotMigrating(slot: Slot, nodeId: String): IO[RedisError, Unit] = {
val command = RedisCommand(
ClusterSetSlots,
Tuple3(LongInput, ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(LongInput, ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
UnitOutput,
codec,
executor
......@@ -98,7 +98,7 @@ trait Cluster extends RedisEnvironment {
final def setSlotImporting(slot: Slot, nodeId: String): IO[RedisError, Unit] = {
val command = RedisCommand(
ClusterSetSlots,
Tuple3(LongInput, ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(LongInput, ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
UnitOutput,
codec,
executor
......@@ -120,7 +120,7 @@ trait Cluster extends RedisEnvironment {
final def setSlotNode(slot: Slot, nodeId: String): IO[RedisError, Unit] = {
val command = RedisCommand(
ClusterSetSlots,
Tuple3(LongInput, ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(LongInput, ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
UnitOutput,
codec,
executor
......
......@@ -44,7 +44,7 @@ trait Geo extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
GeoAdd,
Tuple2(ArbitraryInput[K](), NonEmptyList(Tuple2(LongLatInput, ArbitraryInput[M]()))),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(Tuple2(LongLatInput, ArbitraryValueInput[M]()))),
LongOutput,
codec,
executor
......@@ -74,7 +74,12 @@ trait Geo extends RedisEnvironment {
): IO[RedisError, Option[Double]] = {
val command = RedisCommand(
GeoDist,
Tuple4(ArbitraryInput[K](), ArbitraryInput[M](), ArbitraryInput[M](), OptionalInput(RadiusUnitInput)),
Tuple4(
ArbitraryKeyInput[K](),
ArbitraryValueInput[M](),
ArbitraryValueInput[M](),
OptionalInput(RadiusUnitInput)
),
OptionalOutput(DoubleOutput),
codec,
executor
......@@ -102,7 +107,7 @@ trait Geo extends RedisEnvironment {
): IO[RedisError, Chunk[Option[String]]] = {
val command = RedisCommand(
GeoHash,
Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[M]())),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[M]())),
ChunkOutput(OptionalOutput(MultiStringOutput)),
codec,
executor
......@@ -129,7 +134,13 @@ trait Geo extends RedisEnvironment {
members: M*
): IO[RedisError, Chunk[Option[LongLat]]] = {
val command =
RedisCommand(GeoPos, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[M]())), GeoOutput, codec, executor)
RedisCommand(
GeoPos,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[M]())),
GeoOutput,
codec,
executor
)
command.run((key, (member, members.toList)))
}
......@@ -172,7 +183,7 @@ trait Geo extends RedisEnvironment {
val command = RedisCommand(
GeoRadius,
Tuple9(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
LongLatInput,
DoubleInput,
RadiusUnitInput,
......@@ -235,7 +246,7 @@ trait Geo extends RedisEnvironment {
val command = RedisCommand(
GeoRadius,
Tuple11(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
LongLatInput,
DoubleInput,
RadiusUnitInput,
......@@ -295,8 +306,8 @@ trait Geo extends RedisEnvironment {
val command = RedisCommand(
GeoRadiusByMember,
Tuple9(
ArbitraryInput[K](),
ArbitraryInput[M](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[M](),
DoubleInput,
RadiusUnitInput,
OptionalInput(WithCoordInput),
......@@ -358,8 +369,8 @@ trait Geo extends RedisEnvironment {
val command = RedisCommand(
GeoRadiusByMember,
Tuple11(
ArbitraryInput[K](),
ArbitraryInput[M](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[M](),
DoubleInput,
RadiusUnitInput,
OptionalInput(WithCoordInput),
......
......@@ -40,7 +40,13 @@ trait Hashes extends RedisEnvironment {
*/
final def hDel[K: Schema, F: Schema](key: K, field: F, fields: F*): IO[RedisError, Long] = {
val command =
RedisCommand(HDel, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[F]())), LongOutput, codec, executor)
RedisCommand(
HDel,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[F]())),
LongOutput,
codec,
executor
)
command.run((key, (field, fields.toList)))
}
......@@ -55,7 +61,8 @@ trait Hashes extends RedisEnvironment {
* true if the field exists, otherwise false.
*/
final def hExists[K: Schema, F: Schema](key: K, field: F): IO[RedisError, Boolean] = {
val command = RedisCommand(HExists, Tuple2(ArbitraryInput[K](), ArbitraryInput[F]()), BoolOutput, codec, executor)
val command =
RedisCommand(HExists, Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[F]()), BoolOutput, codec, executor)
command.run((key, field))
}
......@@ -74,7 +81,7 @@ trait Hashes extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(
HGet,
Tuple2(ArbitraryInput[K](), ArbitraryInput[F]()),
Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[F]()),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -95,7 +102,7 @@ trait Hashes extends RedisEnvironment {
val command =
RedisCommand(
HGetAll,
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
KeyValueOutput(ArbitraryOutput[F](), ArbitraryOutput[V]()),
codec,
executor
......@@ -119,7 +126,13 @@ trait Hashes extends RedisEnvironment {
*/
final def hIncrBy[K: Schema, F: Schema](key: K, field: F, increment: Long): IO[RedisError, Long] = {
val command =
RedisCommand(HIncrBy, Tuple3(ArbitraryInput[K](), ArbitraryInput[F](), LongInput), LongOutput, codec, executor)
RedisCommand(
HIncrBy,
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[F](), LongInput),
LongOutput,
codec,
executor
)
command.run((key, field, increment))
}
......@@ -144,7 +157,7 @@ trait Hashes extends RedisEnvironment {
val command =
RedisCommand(
HIncrByFloat,
Tuple3(ArbitraryInput[K](), ArbitraryInput[F](), DoubleInput),
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[F](), DoubleInput),
DoubleOutput,
codec,
executor
......@@ -163,7 +176,7 @@ trait Hashes extends RedisEnvironment {
final def hKeys[K: Schema](key: K): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[F: Schema]: IO[RedisError, Chunk[F]] =
RedisCommand(HKeys, ArbitraryInput[K](), ChunkOutput(ArbitraryOutput[F]()), codec, executor).run(key)
RedisCommand(HKeys, ArbitraryKeyInput[K](), ChunkOutput(ArbitraryOutput[F]()), codec, executor).run(key)
}
/**
......@@ -175,7 +188,7 @@ trait Hashes extends RedisEnvironment {
* number of fields.
*/
final def hLen[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(HLen, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(HLen, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -200,7 +213,7 @@ trait Hashes extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Chunk[Option[V]]] = {
val command = RedisCommand(
HmGet,
Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[F]())),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[F]())),
ChunkOutput(OptionalOutput(ArbitraryOutput[V]())),
codec,
executor
......@@ -229,7 +242,7 @@ trait Hashes extends RedisEnvironment {
): IO[RedisError, Unit] = {
val command = RedisCommand(
HmSet,
Tuple2(ArbitraryInput[K](), NonEmptyList(Tuple2(ArbitraryInput[F](), ArbitraryInput[V]()))),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(Tuple2(ArbitraryValueInput[F](), ArbitraryValueInput[V]()))),
UnitOutput,
codec,
executor
......@@ -261,7 +274,7 @@ trait Hashes extends RedisEnvironment {
def returning[F: Schema, V: Schema]: IO[RedisError, (Long, Chunk[(F, V)])] = {
val command = RedisCommand(
HScan,
Tuple4(ArbitraryInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple4(ArbitraryKeyInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple2Output(ArbitraryOutput[Long](), ChunkTuple2Output(ArbitraryOutput[F](), ArbitraryOutput[V]())),
codec,
executor
......@@ -289,7 +302,7 @@ trait Hashes extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
HSet,
Tuple2(ArbitraryInput[K](), NonEmptyList(Tuple2(ArbitraryInput[F](), ArbitraryInput[V]()))),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(Tuple2(ArbitraryValueInput[F](), ArbitraryValueInput[V]()))),
LongOutput,
codec,
executor
......@@ -317,7 +330,7 @@ trait Hashes extends RedisEnvironment {
val command =
RedisCommand(
HSetNx,
Tuple3(ArbitraryInput[K](), ArbitraryInput[F](), ArbitraryInput[V]()),
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[F](), ArbitraryValueInput[V]()),
BoolOutput,
codec,
executor
......@@ -336,7 +349,8 @@ trait Hashes extends RedisEnvironment {
* string length of the value in field, or zero if either field or key do not exist.
*/
final def hStrLen[K: Schema, F: Schema](key: K, field: F): IO[RedisError, Long] = {
val command = RedisCommand(HStrLen, Tuple2(ArbitraryInput[K](), ArbitraryInput[F]()), LongOutput, codec, executor)
val command =
RedisCommand(HStrLen, Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[F]()), LongOutput, codec, executor)
command.run((key, field))
}
......@@ -351,7 +365,7 @@ trait Hashes extends RedisEnvironment {
final def hVals[K: Schema](key: K): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[V: Schema]: IO[RedisError, Chunk[V]] =
RedisCommand(HVals, ArbitraryInput[K](), ChunkOutput(ArbitraryOutput[V]()), codec, executor).run(key)
RedisCommand(HVals, ArbitraryKeyInput[K](), ChunkOutput(ArbitraryOutput[V]()), codec, executor).run(key)
}
/**
......@@ -365,7 +379,7 @@ trait Hashes extends RedisEnvironment {
final def hRandField[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(HRandField, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
RedisCommand(HRandField, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
}
/**
......@@ -387,7 +401,7 @@ trait Hashes extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Chunk[V]] = {
val command = RedisCommand(
HRandField,
Tuple3(ArbitraryInput[K](), LongInput, OptionalInput(StringInput)),
Tuple3(ArbitraryKeyInput[K](), LongInput, OptionalInput(StringInput)),
ChunkOutput(ArbitraryOutput[V]()),
codec,
executor
......
......@@ -39,7 +39,13 @@ trait HyperLogLog extends RedisEnvironment {
*/
final def pfAdd[K: Schema, V: Schema](key: K, element: V, elements: V*): IO[RedisError, Boolean] = {
val command =
RedisCommand(PfAdd, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[V]())), BoolOutput, codec, executor)
RedisCommand(
PfAdd,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[V]())),
BoolOutput,
codec,
executor
)
command.run((key, (element, elements.toList)))
}
......@@ -54,7 +60,7 @@ trait HyperLogLog extends RedisEnvironment {
* approximate number of unique elements observed via PFADD.
*/
final def pfCount[K: Schema](key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(PfCount, NonEmptyList(ArbitraryInput[K]()), LongOutput, codec, executor)
val command = RedisCommand(PfCount, NonEmptyList(ArbitraryKeyInput[K]()), LongOutput, codec, executor)
command.run((key, keys.toList))
}
......@@ -70,7 +76,13 @@ trait HyperLogLog extends RedisEnvironment {
*/
final def pfMerge[K: Schema](destKey: K, sourceKey: K, sourceKeys: K*): IO[RedisError, Unit] = {
val command =
RedisCommand(PfMerge, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[K]())), UnitOutput, codec, executor)
RedisCommand(
PfMerge,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryKeyInput[K]())),
UnitOutput,
codec,
executor
)
command.run((destKey, (sourceKey, sourceKeys.toList)))
}
}
......
......@@ -42,7 +42,7 @@ trait Keys extends RedisEnvironment {
* [[unlink]]
*/
final def del[K: Schema](key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(Del, NonEmptyList(ArbitraryInput[K]()), LongOutput, codec, executor)
val command = RedisCommand(Del, NonEmptyList(ArbitraryKeyInput[K]()), LongOutput, codec, executor)
command.run((key, keys.toList))
}
......@@ -55,7 +55,7 @@ trait Keys extends RedisEnvironment {
* bytes for value stored at key.
*/
final def dump[K: Schema](key: K): IO[RedisError, Chunk[Byte]] = {
val command = RedisCommand(Dump, ArbitraryInput[K](), BulkStringOutput, codec, executor)
val command = RedisCommand(Dump, ArbitraryKeyInput[K](), BulkStringOutput, codec, executor)
command.run(key)
}
......@@ -71,7 +71,7 @@ trait Keys extends RedisEnvironment {
* The number of keys existing.
*/
final def exists[K: Schema](key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(Exists, NonEmptyList(ArbitraryInput[K]()), LongOutput, codec, executor)
val command = RedisCommand(Exists, NonEmptyList(ArbitraryKeyInput[K]()), LongOutput, codec, executor)
command.run((key, keys.toList))
}
......@@ -89,7 +89,8 @@ trait Keys extends RedisEnvironment {
* [[expireAt]]
*/
final def expire[K: Schema](key: K, timeout: Duration): IO[RedisError, Boolean] = {
val command = RedisCommand(Expire, Tuple2(ArbitraryInput[K](), DurationSecondsInput), BoolOutput, codec, executor)
val command =
RedisCommand(Expire, Tuple2(ArbitraryKeyInput[K](), DurationSecondsInput), BoolOutput, codec, executor)
command.run((key, timeout))
}
......@@ -107,7 +108,7 @@ trait Keys extends RedisEnvironment {
* [[expire]]
*/
final def expireAt[K: Schema](key: K, timestamp: Instant): IO[RedisError, Boolean] = {
val command = RedisCommand(ExpireAt, Tuple2(ArbitraryInput[K](), TimeSecondsInput), BoolOutput, codec, executor)
val command = RedisCommand(ExpireAt, Tuple2(ArbitraryKeyInput[K](), TimeSecondsInput), BoolOutput, codec, executor)
command.run((key, timestamp))
}
......@@ -166,13 +167,13 @@ trait Keys extends RedisEnvironment {
Tuple9(
StringInput,
LongInput,
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
LongInput,
LongInput,
OptionalInput(CopyInput),
OptionalInput(ReplaceInput),
OptionalInput(AuthInput),
OptionalInput(NonEmptyList(ArbitraryInput[K]()))
OptionalInput(NonEmptyList(ArbitraryKeyInput[K]()))
),
StringOutput,
codec,
......@@ -193,7 +194,7 @@ trait Keys extends RedisEnvironment {
* true if the key was moved.
*/
final def move[K: Schema](key: K, destinationDb: Long): IO[RedisError, Boolean] = {
val command = RedisCommand(Move, Tuple2(ArbitraryInput[K](), LongInput), BoolOutput, codec, executor)
val command = RedisCommand(Move, Tuple2(ArbitraryKeyInput[K](), LongInput), BoolOutput, codec, executor)
command.run((key, destinationDb))
}
......@@ -206,7 +207,7 @@ trait Keys extends RedisEnvironment {
* true if timeout was removed, false if key does not exist or does not have an associated timeout.
*/
final def persist[K: Schema](key: K): IO[RedisError, Boolean] = {
val command = RedisCommand(Persist, ArbitraryInput[K](), BoolOutput, codec, executor)
val command = RedisCommand(Persist, ArbitraryKeyInput[K](), BoolOutput, codec, executor)
command.run(key)
}
......@@ -225,7 +226,7 @@ trait Keys extends RedisEnvironment {
*/
final def pExpire[K: Schema](key: K, timeout: Duration): IO[RedisError, Boolean] = {
val command =
RedisCommand(PExpire, Tuple2(ArbitraryInput[K](), DurationMillisecondsInput), BoolOutput, codec, executor)
RedisCommand(PExpire, Tuple2(ArbitraryKeyInput[K](), DurationMillisecondsInput), BoolOutput, codec, executor)
command.run((key, timeout))
}
......@@ -244,7 +245,7 @@ trait Keys extends RedisEnvironment {
*/
final def pExpireAt[K: Schema](key: K, timestamp: Instant): IO[RedisError, Boolean] = {
val command =
RedisCommand(PExpireAt, Tuple2(ArbitraryInput[K](), TimeMillisecondsInput), BoolOutput, codec, executor)
RedisCommand(PExpireAt, Tuple2(ArbitraryKeyInput[K](), TimeMillisecondsInput), BoolOutput, codec, executor)
command.run((key, timestamp))
}
......@@ -257,7 +258,7 @@ trait Keys extends RedisEnvironment {
* remaining time to live of a key that has a timeout, error otherwise.
*/
final def pTtl[K: Schema](key: K): IO[RedisError, Duration] = {
val command = RedisCommand(PTtl, ArbitraryInput[K](), DurationMillisecondsOutput, codec, executor)
val command = RedisCommand(PTtl, ArbitraryKeyInput[K](), DurationMillisecondsOutput, codec, executor)
command.run(key)
}
......@@ -284,7 +285,8 @@ trait Keys extends RedisEnvironment {
* unit if successful, error otherwise.
*/
final def rename[K: Schema](key: K, newKey: K): IO[RedisError, Unit] = {
val command = RedisCommand(Rename, Tuple2(ArbitraryInput[K](), ArbitraryInput[K]()), UnitOutput, codec, executor)
val command =
RedisCommand(Rename, Tuple2(ArbitraryKeyInput[K](), ArbitraryKeyInput[K]()), UnitOutput, codec, executor)
command.run((key, newKey))
}
......@@ -299,7 +301,8 @@ trait Keys extends RedisEnvironment {
* true if key was renamed to newKey, false if newKey already exists.
*/
final def renameNx[K: Schema](key: K, newKey: K): IO[RedisError, Boolean] = {
val command = RedisCommand(RenameNx, Tuple2(ArbitraryInput[K](), ArbitraryInput[K]()), BoolOutput, codec, executor)
val command =
RedisCommand(RenameNx, Tuple2(ArbitraryKeyInput[K](), ArbitraryKeyInput[K]()), BoolOutput, codec, executor)
command.run((key, newKey))
}
......@@ -337,9 +340,9 @@ trait Keys extends RedisEnvironment {
val command = RedisCommand(
Restore,
Tuple7(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
LongInput,
ByteInput,
ValueInput,
OptionalInput(ReplaceInput),
OptionalInput(AbsTtlInput),
OptionalInput(IdleTimeInput),
......@@ -418,7 +421,7 @@ trait Keys extends RedisEnvironment {
val command = RedisCommand(
Sort,
Tuple6(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
OptionalInput(ByInput),
OptionalInput(LimitInput),
OptionalInput(NonEmptyList(GetInput)),
......@@ -469,7 +472,7 @@ trait Keys extends RedisEnvironment {
val command = RedisCommand(
SortStore,
Tuple7(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
OptionalInput(ByInput),
OptionalInput(LimitInput),
OptionalInput(NonEmptyList(GetInput)),
......@@ -495,7 +498,7 @@ trait Keys extends RedisEnvironment {
* The number of keys that were touched.
*/
final def touch[K: Schema](key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(Touch, NonEmptyList(ArbitraryInput[K]()), LongOutput, codec, executor)
val command = RedisCommand(Touch, NonEmptyList(ArbitraryKeyInput[K]()), LongOutput, codec, executor)
command.run((key, keys.toList))
}
......@@ -508,7 +511,7 @@ trait Keys extends RedisEnvironment {
* remaining time to live of a key that has a timeout, error otherwise.
*/
final def ttl[K: Schema](key: K): IO[RedisError, Duration] = {
val command = RedisCommand(Ttl, ArbitraryInput[K](), DurationSecondsOutput, codec, executor)
val command = RedisCommand(Ttl, ArbitraryKeyInput[K](), DurationSecondsOutput, codec, executor)
command.run(key)
}
......@@ -521,7 +524,7 @@ trait Keys extends RedisEnvironment {
* type of the value stored at key.
*/
final def typeOf[K: Schema](key: K): IO[RedisError, RedisType] = {
val command = RedisCommand(TypeOf, ArbitraryInput[K](), TypeOutput, codec, executor)
val command = RedisCommand(TypeOf, ArbitraryKeyInput[K](), TypeOutput, codec, executor)
command.run(key)
}
......@@ -540,7 +543,7 @@ trait Keys extends RedisEnvironment {
* [[del]]
*/
final def unlink[K: Schema](key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(Unlink, NonEmptyList(ArbitraryInput[K]()), LongOutput, codec, executor)
val command = RedisCommand(Unlink, NonEmptyList(ArbitraryKeyInput[K]()), LongOutput, codec, executor)
command.run((key, keys.toList))
}
......
......@@ -49,7 +49,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] = {
val command = RedisCommand(
BrPopLPush,
Tuple3(ArbitraryInput[S](), ArbitraryInput[D](), DurationSecondsInput),
Tuple3(ArbitraryValueInput[S](), ArbitraryValueInput[D](), DurationSecondsInput),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -75,7 +75,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(
LIndex,
Tuple2(ArbitraryInput[K](), LongInput),
Tuple2(ArbitraryKeyInput[K](), LongInput),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -92,7 +92,7 @@ trait Lists extends RedisEnvironment {
* the length of the list at key.
*/
final def lLen[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(LLen, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(LLen, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -107,7 +107,7 @@ trait Lists extends RedisEnvironment {
final def lPop[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(LPop, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
RedisCommand(LPop, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
}
/**
......@@ -125,7 +125,13 @@ trait Lists extends RedisEnvironment {
*/
final def lPush[K: Schema, V: Schema](key: K, element: V, elements: V*): IO[RedisError, Long] = {
val command =
RedisCommand(LPush, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[V]())), LongOutput, codec, executor)
RedisCommand(
LPush,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[V]())),
LongOutput,
codec,
executor
)
command.run((key, (element, elements.toList)))
}
......@@ -144,7 +150,13 @@ trait Lists extends RedisEnvironment {
*/
final def lPushX[K: Schema, V: Schema](key: K, element: V, elements: V*): IO[RedisError, Long] = {
val command =
RedisCommand(LPushX, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[V]())), LongOutput, codec, executor)
RedisCommand(
LPushX,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[V]())),
LongOutput,
codec,
executor
)
command.run((key, (element, elements.toList)))
}
......@@ -164,7 +176,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Chunk[V]] =
RedisCommand(
LRange,
Tuple2(ArbitraryInput[K](), RangeInput),
Tuple2(ArbitraryKeyInput[K](), RangeInput),
ChunkOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -190,7 +202,8 @@ trait Lists extends RedisEnvironment {
* the number of removed elements.
*/
final def lRem[K: Schema](key: K, count: Long, element: String): IO[RedisError, Long] = {
val command = RedisCommand(LRem, Tuple3(ArbitraryInput[K](), LongInput, StringInput), LongOutput, codec, executor)
val command =
RedisCommand(LRem, Tuple3(ArbitraryKeyInput[K](), LongInput, StringInput), LongOutput, codec, executor)
command.run((key, count, element))
}
......@@ -208,7 +221,13 @@ trait Lists extends RedisEnvironment {
*/
final def lSet[K: Schema, V: Schema](key: K, index: Long, element: V): IO[RedisError, Unit] = {
val command =
RedisCommand(LSet, Tuple3(ArbitraryInput[K](), LongInput, ArbitraryInput[V]()), UnitOutput, codec, executor)
RedisCommand(
LSet,
Tuple3(ArbitraryKeyInput[K](), LongInput, ArbitraryValueInput[V]()),
UnitOutput,
codec,
executor
)
command.run((key, index, element))
}
......@@ -224,7 +243,7 @@ trait Lists extends RedisEnvironment {
* the Unit value.
*/
final def lTrim[K: Schema](key: K, range: Range): IO[RedisError, Unit] = {
val command = RedisCommand(LTrim, Tuple2(ArbitraryInput[K](), RangeInput), UnitOutput, codec, executor)
val command = RedisCommand(LTrim, Tuple2(ArbitraryKeyInput[K](), RangeInput), UnitOutput, codec, executor)
command.run((key, range))
}
......@@ -239,7 +258,7 @@ trait Lists extends RedisEnvironment {
final def rPop[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(RPop, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
RedisCommand(RPop, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[V]()), codec, executor).run(key)
}
/**
......@@ -259,7 +278,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] =
RedisCommand(
RPopLPush,
Tuple2(ArbitraryInput[S](), ArbitraryInput[D]()),
Tuple2(ArbitraryValueInput[S](), ArbitraryValueInput[D]()),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -282,7 +301,13 @@ trait Lists extends RedisEnvironment {
*/
final def rPush[K: Schema, V: Schema](key: K, element: V, elements: V*): IO[RedisError, Long] = {
val command =
RedisCommand(RPush, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[V]())), LongOutput, codec, executor)
RedisCommand(
RPush,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[V]())),
LongOutput,
codec,
executor
)
command.run((key, (element, elements.toList)))
}
......@@ -301,7 +326,13 @@ trait Lists extends RedisEnvironment {
*/
final def rPushX[K: Schema, V: Schema](key: K, element: V, elements: V*): IO[RedisError, Long] = {
val command =
RedisCommand(RPushX, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[V]())), LongOutput, codec, executor)
RedisCommand(
RPushX,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[V]())),
LongOutput,
codec,
executor
)
command.run((key, (element, elements.toList)))
}
......@@ -327,7 +358,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[(K, V)]] = {
val command = RedisCommand(
BlPop,
Tuple2(NonEmptyList(ArbitraryInput[K]()), DurationSecondsInput),
Tuple2(NonEmptyList(ArbitraryKeyInput[K]()), DurationSecondsInput),
OptionalOutput(Tuple2Output(ArbitraryOutput[K](), ArbitraryOutput[V]())),
codec,
executor
......@@ -358,7 +389,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[(K, V)]] = {
val command = RedisCommand(
BrPop,
Tuple2(NonEmptyList(ArbitraryInput[K]()), DurationSecondsInput),
Tuple2(NonEmptyList(ArbitraryKeyInput[K]()), DurationSecondsInput),
OptionalOutput(Tuple2Output(ArbitraryOutput[K](), ArbitraryOutput[V]())),
codec,
executor
......@@ -389,7 +420,7 @@ trait Lists extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
LInsert,
Tuple4(ArbitraryInput[K](), PositionInput, ArbitraryInput[V](), ArbitraryInput[V]()),
Tuple4(ArbitraryKeyInput[K](), PositionInput, ArbitraryValueInput[V](), ArbitraryValueInput[V]()),
LongOutput,
codec,
executor
......@@ -423,7 +454,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] = {
val command = RedisCommand(
LMove,
Tuple4(ArbitraryInput[S](), ArbitraryInput[D](), SideInput, SideInput),
Tuple4(ArbitraryValueInput[S](), ArbitraryValueInput[D](), SideInput, SideInput),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -462,7 +493,7 @@ trait Lists extends RedisEnvironment {
def returning[V: Schema]: IO[RedisError, Option[V]] = {
val command = RedisCommand(
BlMove,
Tuple5(ArbitraryInput[S](), ArbitraryInput[D](), SideInput, SideInput, DurationSecondsInput),
Tuple5(ArbitraryValueInput[S](), ArbitraryValueInput[D](), SideInput, SideInput, DurationSecondsInput),
OptionalOutput(ArbitraryOutput[V]()),
codec,
executor
......@@ -497,8 +528,8 @@ trait Lists extends RedisEnvironment {
val command = RedisCommand(
LPos,
Tuple4(
ArbitraryInput[K](),
ArbitraryInput[V](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[V](),
OptionalInput(RankInput),
OptionalInput(ListMaxLenInput)
),
......@@ -538,8 +569,8 @@ trait Lists extends RedisEnvironment {
val command = RedisCommand(
LPos,
Tuple5(
ArbitraryInput[K](),
ArbitraryInput[V](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[V](),
CountInput,
OptionalInput(RankInput),
OptionalInput(ListMaxLenInput)
......
......@@ -41,7 +41,13 @@ trait Sets extends RedisEnvironment {
*/
final def sAdd[K: Schema, M: Schema](key: K, member: M, members: M*): IO[RedisError, Long] = {
val command =
RedisCommand(SAdd, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[M]())), LongOutput, codec, executor)
RedisCommand(
SAdd,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[M]())),
LongOutput,
codec,
executor
)
command.run((key, (member, members.toList)))
}
......@@ -54,7 +60,7 @@ trait Sets extends RedisEnvironment {
* Returns the cardinality (number of elements) of the set, or 0 if key does not exist.
*/
final def sCard[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(SCard, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(SCard, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -71,7 +77,7 @@ trait Sets extends RedisEnvironment {
final def sDiff[K: Schema](key: K, keys: K*): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[R: Schema]: IO[RedisError, Chunk[R]] =
RedisCommand(SDiff, NonEmptyList(ArbitraryInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
RedisCommand(SDiff, NonEmptyList(ArbitraryKeyInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
.run((key, keys.toList))
}
......@@ -90,7 +96,7 @@ trait Sets extends RedisEnvironment {
final def sDiffStore[D: Schema, K: Schema](destination: D, key: K, keys: K*): IO[RedisError, Long] = {
val command = RedisCommand(
SDiffStore,
Tuple2(ArbitraryInput[D](), NonEmptyList(ArbitraryInput[K]())),
Tuple2(ArbitraryValueInput[D](), NonEmptyList(ArbitraryKeyInput[K]())),
LongOutput,
codec,
executor
......@@ -111,7 +117,7 @@ trait Sets extends RedisEnvironment {
final def sInter[K: Schema](destination: K, keys: K*): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[R: Schema]: IO[RedisError, Chunk[R]] =
RedisCommand(SInter, NonEmptyList(ArbitraryInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
RedisCommand(SInter, NonEmptyList(ArbitraryKeyInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
.run((destination, keys.toList))
}
......@@ -134,7 +140,7 @@ trait Sets extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
SInterStore,
Tuple2(ArbitraryInput[D](), NonEmptyList(ArbitraryInput[K]())),
Tuple2(ArbitraryValueInput[D](), NonEmptyList(ArbitraryKeyInput[K]())),
LongOutput,
codec,
executor
......@@ -154,7 +160,8 @@ trait Sets extends RedisEnvironment {
* exist.
*/
final def sIsMember[K: Schema, M: Schema](key: K, member: M): IO[RedisError, Boolean] = {
val command = RedisCommand(SIsMember, Tuple2(ArbitraryInput[K](), ArbitraryInput[M]()), BoolOutput, codec, executor)
val command =
RedisCommand(SIsMember, Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[M]()), BoolOutput, codec, executor)
command.run((key, member))
}
......@@ -169,7 +176,7 @@ trait Sets extends RedisEnvironment {
final def sMembers[K: Schema](key: K): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[R: Schema]: IO[RedisError, Chunk[R]] =
RedisCommand(SMembers, ArbitraryInput[K](), ChunkOutput(ArbitraryOutput[R]()), codec, executor).run(key)
RedisCommand(SMembers, ArbitraryKeyInput[K](), ChunkOutput(ArbitraryOutput[R]()), codec, executor).run(key)
}
/**
......@@ -191,7 +198,7 @@ trait Sets extends RedisEnvironment {
): IO[RedisError, Boolean] = {
val command = RedisCommand(
SMove,
Tuple3(ArbitraryInput[S](), ArbitraryInput[D](), ArbitraryInput[M]()),
Tuple3(ArbitraryValueInput[S](), ArbitraryValueInput[D](), ArbitraryValueInput[M]()),
BoolOutput,
codec,
executor
......@@ -214,7 +221,7 @@ trait Sets extends RedisEnvironment {
def returning[R: Schema]: IO[RedisError, Chunk[R]] = {
val command = RedisCommand(
SPop,
Tuple2(ArbitraryInput[K](), OptionalInput(LongInput)),
Tuple2(ArbitraryKeyInput[K](), OptionalInput(LongInput)),
MultiStringChunkOutput(ArbitraryOutput[R]()),
codec,
executor
......@@ -238,7 +245,7 @@ trait Sets extends RedisEnvironment {
def returning[R: Schema]: IO[RedisError, Chunk[R]] = {
val command = RedisCommand(
SRandMember,
Tuple2(ArbitraryInput[K](), OptionalInput(LongInput)),
Tuple2(ArbitraryKeyInput[K](), OptionalInput(LongInput)),
MultiStringChunkOutput(ArbitraryOutput[R]()),
codec,
executor
......@@ -261,7 +268,13 @@ trait Sets extends RedisEnvironment {
*/
final def sRem[K: Schema, M: Schema](key: K, member: M, members: M*): IO[RedisError, Long] = {
val command =
RedisCommand(SRem, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[M]())), LongOutput, codec, executor)
RedisCommand(
SRem,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[M]())),
LongOutput,
codec,
executor
)
command.run((key, (member, members.toList)))
}
......@@ -292,7 +305,7 @@ trait Sets extends RedisEnvironment {
def returning[R: Schema]: IO[RedisError, (Long, Chunk[R])] = {
val command = RedisCommand(
SScan,
Tuple4(ArbitraryInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple4(ArbitraryKeyInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple2Output(MultiStringOutput.map(_.toLong), ChunkOutput(ArbitraryOutput[R]())),
codec,
executor
......@@ -314,7 +327,7 @@ trait Sets extends RedisEnvironment {
final def sUnion[K: Schema](key: K, keys: K*): ResultBuilder1[Chunk] =
new ResultBuilder1[Chunk] {
def returning[R: Schema]: IO[RedisError, Chunk[R]] =
RedisCommand(SUnion, NonEmptyList(ArbitraryInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
RedisCommand(SUnion, NonEmptyList(ArbitraryKeyInput[K]()), ChunkOutput(ArbitraryOutput[R]()), codec, executor)
.run((key, keys.toList))
}
......@@ -337,7 +350,7 @@ trait Sets extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
SUnionStore,
Tuple2(ArbitraryInput[D](), NonEmptyList(ArbitraryInput[K]())),
Tuple2(ArbitraryValueInput[D](), NonEmptyList(ArbitraryKeyInput[K]())),
LongOutput,
codec,
executor
......
......@@ -53,7 +53,7 @@ trait SortedSets extends RedisEnvironment {
}
val command = RedisCommand(
BzPopMax,
Tuple2(NonEmptyList(ArbitraryInput[K]()), DurationSecondsInput),
Tuple2(NonEmptyList(ArbitraryKeyInput[K]()), DurationSecondsInput),
OptionalOutput(memberScoreOutput),
codec,
executor
......@@ -89,7 +89,7 @@ trait SortedSets extends RedisEnvironment {
}
val command = RedisCommand(
BzPopMin,
Tuple2(NonEmptyList(ArbitraryInput[K]()), DurationSecondsInput),
Tuple2(NonEmptyList(ArbitraryKeyInput[K]()), DurationSecondsInput),
OptionalOutput(memberScoreOutput),
codec,
executor
......@@ -122,7 +122,7 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZAdd,
Tuple4(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
OptionalInput(UpdateInput),
OptionalInput(ChangedInput),
NonEmptyList(MemberScoreInput[M]())
......@@ -161,7 +161,7 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZAdd,
Tuple5(
ArbitraryInput[K](),
ArbitraryKeyInput[K](),
OptionalInput(UpdateInput),
OptionalInput(ChangedInput),
IncrementInput,
......@@ -183,7 +183,7 @@ trait SortedSets extends RedisEnvironment {
* The cardinality (number of elements) of the sorted set, or 0 if key does not exist.
*/
final def zCard[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(ZCard, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(ZCard, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -198,7 +198,7 @@ trait SortedSets extends RedisEnvironment {
* the number of elements in the specified score range.
*/
final def zCount[K: Schema](key: K, range: Range): IO[RedisError, Long] = {
val command = RedisCommand(ZCount, Tuple2(ArbitraryInput[K](), RangeInput), LongOutput, codec, executor)
val command = RedisCommand(ZCount, Tuple2(ArbitraryKeyInput[K](), RangeInput), LongOutput, codec, executor)
command.run((key, range))
}
......@@ -226,7 +226,7 @@ trait SortedSets extends RedisEnvironment {
ZDiff,
Tuple2(
LongInput,
NonEmptyList(ArbitraryInput[K]())
NonEmptyList(ArbitraryKeyInput[K]())
),
ChunkOutput(ArbitraryOutput[M]()),
codec,
......@@ -260,8 +260,8 @@ trait SortedSets extends RedisEnvironment {
ZDiff,
Tuple3(
LongInput,
NonEmptyList(ArbitraryInput[K]()),
ArbitraryInput[String]()
NonEmptyList(ArbitraryKeyInput[K]()),
ArbitraryValueInput[String]()
),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
......@@ -296,9 +296,9 @@ trait SortedSets extends RedisEnvironment {
RedisCommand(
ZDiffStore,
Tuple3(
ArbitraryInput[DK](),
ArbitraryValueInput[DK](),
LongInput,
NonEmptyList(ArbitraryInput[K]())
NonEmptyList(ArbitraryKeyInput[K]())
),
LongOutput,
codec,
......@@ -325,7 +325,13 @@ trait SortedSets extends RedisEnvironment {
member: M
): IO[RedisError, Double] = {
val command =
RedisCommand(ZIncrBy, Tuple3(ArbitraryInput[K](), LongInput, ArbitraryInput[M]()), DoubleOutput, codec, executor)
RedisCommand(
ZIncrBy,
Tuple3(ArbitraryKeyInput[K](), LongInput, ArbitraryValueInput[M]()),
DoubleOutput,
codec,
executor
)
command.run((key, increment, member))
}
......@@ -357,7 +363,7 @@ trait SortedSets extends RedisEnvironment {
ZInter,
Tuple4(
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(AggregateInput),
OptionalInput(WeightsInput)
),
......@@ -397,10 +403,10 @@ trait SortedSets extends RedisEnvironment {
ZInter,
Tuple5(
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(AggregateInput),
OptionalInput(WeightsInput),
ArbitraryInput[String]()
ArbitraryValueInput[String]()
),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
......@@ -438,9 +444,9 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZInterStore,
Tuple5(
ArbitraryInput[DK](),
ArbitraryValueInput[DK](),
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(AggregateInput),
OptionalInput(WeightsInput)
),
......@@ -464,7 +470,7 @@ trait SortedSets extends RedisEnvironment {
final def zLexCount[K: Schema](key: K, lexRange: LexRange): IO[RedisError, Long] = {
val command = RedisCommand(
ZLexCount,
Tuple3(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
LongOutput,
codec,
executor
......@@ -492,7 +498,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[MemberScore[M]]] = {
val command = RedisCommand(
ZPopMax,
Tuple2(ArbitraryInput[K](), OptionalInput(LongInput)),
Tuple2(ArbitraryKeyInput[K](), OptionalInput(LongInput)),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
codec,
......@@ -522,7 +528,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[MemberScore[M]]] = {
val command = RedisCommand(
ZPopMin,
Tuple2(ArbitraryInput[K](), OptionalInput(LongInput)),
Tuple2(ArbitraryKeyInput[K](), OptionalInput(LongInput)),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
codec,
......@@ -547,7 +553,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRange,
Tuple2(ArbitraryInput[K](), RangeInput),
Tuple2(ArbitraryKeyInput[K](), RangeInput),
ChunkOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -574,7 +580,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[MemberScore[M]]] = {
val command = RedisCommand(
ZRange,
Tuple3(ArbitraryInput[K](), RangeInput, ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), RangeInput, ArbitraryValueInput[String]()),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
codec,
......@@ -606,7 +612,12 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRangeByLex,
Tuple4(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String](), OptionalInput(LimitInput)),
Tuple4(
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -637,7 +648,12 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRangeByScore,
Tuple4(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String](), OptionalInput(LimitInput)),
Tuple4(
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -669,10 +685,10 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZRangeByScore,
Tuple5(
ArbitraryInput[K](),
ArbitraryInput[String](),
ArbitraryInput[String](),
ArbitraryInput[String](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
......@@ -696,7 +712,13 @@ trait SortedSets extends RedisEnvironment {
*/
final def zRank[K: Schema, M: Schema](key: K, member: M): IO[RedisError, Option[Long]] = {
val command =
RedisCommand(ZRank, Tuple2(ArbitraryInput[K](), ArbitraryInput[M]()), OptionalOutput(LongOutput), codec, executor)
RedisCommand(
ZRank,
Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[M]()),
OptionalOutput(LongOutput),
codec,
executor
)
command.run((key, member))
}
......@@ -718,7 +740,13 @@ trait SortedSets extends RedisEnvironment {
restMembers: M*
): IO[RedisError, Long] = {
val command =
RedisCommand(ZRem, Tuple2(ArbitraryInput[K](), NonEmptyList(ArbitraryInput[M]())), LongOutput, codec, executor)
RedisCommand(
ZRem,
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(ArbitraryValueInput[M]())),
LongOutput,
codec,
executor
)
command.run((key, (firstMember, restMembers.toList)))
}
......@@ -735,7 +763,7 @@ trait SortedSets extends RedisEnvironment {
final def zRemRangeByLex[K: Schema](key: K, lexRange: LexRange): IO[RedisError, Long] = {
val command = RedisCommand(
ZRemRangeByLex,
Tuple3(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
LongOutput,
codec,
executor
......@@ -754,7 +782,7 @@ trait SortedSets extends RedisEnvironment {
* The number of elements removed.
*/
final def zRemRangeByRank[K: Schema](key: K, range: Range): IO[RedisError, Long] = {
val command = RedisCommand(ZRemRangeByRank, Tuple2(ArbitraryInput[K](), RangeInput), LongOutput, codec, executor)
val command = RedisCommand(ZRemRangeByRank, Tuple2(ArbitraryKeyInput[K](), RangeInput), LongOutput, codec, executor)
command.run((key, range))
}
......@@ -771,7 +799,7 @@ trait SortedSets extends RedisEnvironment {
final def zRemRangeByScore[K: Schema](key: K, scoreRange: ScoreRange): IO[RedisError, Long] = {
val command = RedisCommand(
ZRemRangeByScore,
Tuple3(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), ArbitraryValueInput[String](), ArbitraryValueInput[String]()),
LongOutput,
codec,
executor
......@@ -794,7 +822,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRevRange,
Tuple2(ArbitraryInput[K](), RangeInput),
Tuple2(ArbitraryKeyInput[K](), RangeInput),
ChunkOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -821,7 +849,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[MemberScore[M]]] = {
val command = RedisCommand(
ZRevRange,
Tuple3(ArbitraryInput[K](), RangeInput, ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), RangeInput, ArbitraryValueInput[String]()),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
codec,
......@@ -853,7 +881,12 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRevRangeByLex,
Tuple4(ArbitraryInput[K](), ArbitraryInput[String](), ArbitraryInput[String](), OptionalInput(LimitInput)),
Tuple4(
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -885,9 +918,9 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZRevRangeByScore,
Tuple4(
ArbitraryInput[K](),
ArbitraryInput[String](),
ArbitraryInput[String](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkOutput(ArbitraryOutput[M]()),
......@@ -921,10 +954,10 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZRevRangeByScore,
Tuple5(
ArbitraryInput[K](),
ArbitraryInput[String](),
ArbitraryInput[String](),
ArbitraryInput[String](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
ArbitraryValueInput[String](),
OptionalInput(LimitInput)
),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
......@@ -949,7 +982,7 @@ trait SortedSets extends RedisEnvironment {
final def zRevRank[K: Schema, M: Schema](key: K, member: M): IO[RedisError, Option[Long]] = {
val command = RedisCommand(
ZRevRank,
Tuple2(ArbitraryInput[K](), ArbitraryInput[M]()),
Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[M]()),
OptionalOutput(LongOutput),
codec,
executor
......@@ -983,7 +1016,7 @@ trait SortedSets extends RedisEnvironment {
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput).map(_.map { case (m, s) => MemberScore(s, m) })
val command = RedisCommand(
ZScan,
Tuple4(ArbitraryInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple4(ArbitraryKeyInput[K](), LongInput, OptionalInput(PatternInput), OptionalInput(CountInput)),
Tuple2Output(MultiStringOutput.map(_.toLong), memberScoresOutput),
codec,
executor
......@@ -1005,7 +1038,7 @@ trait SortedSets extends RedisEnvironment {
final def zScore[K: Schema, M: Schema](key: K, member: M): IO[RedisError, Option[Double]] = {
val command = RedisCommand(
ZScore,
Tuple2(ArbitraryInput[K](), ArbitraryInput[M]()),
Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[M]()),
OptionalOutput(DoubleOutput),
codec,
executor
......@@ -1042,7 +1075,7 @@ trait SortedSets extends RedisEnvironment {
ZUnion,
Tuple4(
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(WeightsInput),
OptionalInput(AggregateInput)
),
......@@ -1083,10 +1116,10 @@ trait SortedSets extends RedisEnvironment {
ZUnion,
Tuple5(
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(WeightsInput),
OptionalInput(AggregateInput),
ArbitraryInput[String]()
ArbitraryValueInput[String]()
),
ChunkTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
......@@ -1124,9 +1157,9 @@ trait SortedSets extends RedisEnvironment {
val command = RedisCommand(
ZUnionStore,
Tuple5(
ArbitraryInput[DK](),
ArbitraryValueInput[DK](),
LongInput,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
OptionalInput(WeightsInput),
OptionalInput(AggregateInput)
),
......@@ -1150,7 +1183,7 @@ trait SortedSets extends RedisEnvironment {
final def zMScore[K: Schema](key: K, keys: K*): IO[RedisError, Chunk[Option[Double]]] = {
val command = RedisCommand(
ZMScore,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
ChunkOutput(OptionalOutput(DoubleOutput)),
codec,
executor
......@@ -1169,7 +1202,8 @@ trait SortedSets extends RedisEnvironment {
final def zRandMember[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[R: Schema]: IO[RedisError, Option[R]] =
RedisCommand(ZRandMember, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor).run(key)
RedisCommand(ZRandMember, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor)
.run(key)
}
/**
......@@ -1191,7 +1225,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[M]] = {
val command = RedisCommand(
ZRandMember,
Tuple2(ArbitraryInput[K](), LongInput),
Tuple2(ArbitraryKeyInput[K](), LongInput),
ZRandMemberOutput(ArbitraryOutput[M]()),
codec,
executor
......@@ -1221,7 +1255,7 @@ trait SortedSets extends RedisEnvironment {
def returning[M: Schema]: IO[RedisError, Chunk[MemberScore[M]]] = {
val command = RedisCommand(
ZRandMember,
Tuple3(ArbitraryInput[K](), LongInput, ArbitraryInput[String]()),
Tuple3(ArbitraryKeyInput[K](), LongInput, ArbitraryValueInput[String]()),
ZRandMemberTuple2Output(ArbitraryOutput[M](), DoubleOutput)
.map(_.map { case (m, s) => MemberScore(s, m) }),
codec,
......
......@@ -50,7 +50,7 @@ trait Streams extends RedisEnvironment {
): IO[RedisError, Long] = {
val command = RedisCommand(
XAck,
Tuple3(ArbitraryInput[SK](), ArbitraryInput[G](), NonEmptyList(ArbitraryInput[I]())),
Tuple3(ArbitraryKeyInput[SK](), ArbitraryValueInput[G](), NonEmptyList(ArbitraryValueInput[I]())),
LongOutput,
codec,
executor
......@@ -83,10 +83,10 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XAdd,
Tuple4(
ArbitraryInput[SK](),
ArbitraryKeyInput[SK](),
OptionalInput(StreamMaxLenInput),
ArbitraryInput[I](),
NonEmptyList(Tuple2(ArbitraryInput[K](), ArbitraryInput[V]()))
ArbitraryValueInput[I](),
NonEmptyList(Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]()))
),
ArbitraryOutput[R](),
codec,
......@@ -108,7 +108,7 @@ trait Streams extends RedisEnvironment {
key: SK
): ResultBuilder3[StreamInfo] = new ResultBuilder3[StreamInfo] {
def returning[RI: Schema, RK: Schema, RV: Schema]: IO[RedisError, StreamInfo[RI, RK, RV]] = {
val command = RedisCommand(XInfoStream, ArbitraryInput[SK](), StreamInfoOutput[RI, RK, RV](), codec, executor)
val command = RedisCommand(XInfoStream, ArbitraryKeyInput[SK](), StreamInfoOutput[RI, RK, RV](), codec, executor)
command.run(key)
}
}
......@@ -127,7 +127,7 @@ trait Streams extends RedisEnvironment {
def returning[RI: Schema, RK: Schema, RV: Schema]: IO[RedisError, FullStreamInfo[RI, RK, RV]] = {
val command = RedisCommand(
XInfoStream,
Tuple2(ArbitraryInput[SK](), ArbitraryInput[String]()),
Tuple2(ArbitraryKeyInput[SK](), ArbitraryValueInput[String]()),
StreamInfoFullOutput[RI, RK, RV](),
codec,
executor
......@@ -153,7 +153,7 @@ trait Streams extends RedisEnvironment {
def returning[RI: Schema, RK: Schema, RV: Schema]: IO[RedisError, FullStreamInfo[RI, RK, RV]] = {
val command = RedisCommand(
XInfoStream,
Tuple3(ArbitraryInput[SK](), ArbitraryInput[String](), CountInput),
Tuple3(ArbitraryKeyInput[SK](), ArbitraryValueInput[String](), CountInput),
StreamInfoFullOutput[RI, RK, RV](),
codec,
executor
......@@ -171,7 +171,7 @@ trait Streams extends RedisEnvironment {
* List of consumer groups associated with the stream stored at the specified key.
*/
final def xInfoGroups[SK: Schema](key: SK): IO[RedisError, Chunk[StreamGroupsInfo]] = {
val command = RedisCommand(XInfoGroups, ArbitraryInput[SK](), StreamGroupsInfoOutput, codec, executor)
val command = RedisCommand(XInfoGroups, ArbitraryKeyInput[SK](), StreamGroupsInfoOutput, codec, executor)
command.run(key)
}
......@@ -192,7 +192,7 @@ trait Streams extends RedisEnvironment {
val command =
RedisCommand(
XInfoConsumers,
Tuple2(ArbitraryInput[SK](), ArbitraryInput[SG]()),
Tuple2(ArbitraryKeyInput[SK](), ArbitraryValueInput[SG]()),
StreamConsumersInfoOutput,
codec,
executor
......@@ -232,10 +232,10 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XAdd,
Tuple4(
ArbitraryInput[SK](),
ArbitraryKeyInput[SK](),
OptionalInput(StreamMaxLenInput),
ArbitraryInput[I](),
NonEmptyList(Tuple2(ArbitraryInput[K](), ArbitraryInput[V]()))
ArbitraryValueInput[I](),
NonEmptyList(Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]()))
),
ArbitraryOutput[R](),
codec,
......@@ -287,11 +287,11 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XClaim,
Tuple9(
ArbitraryInput[SK](),
ArbitraryInput[SG](),
ArbitraryInput[SC](),
ArbitraryKeyInput[SK](),
ArbitraryValueInput[SG](),
ArbitraryValueInput[SC](),
DurationMillisecondsInput,
NonEmptyList(ArbitraryInput[I]()),
NonEmptyList(ArbitraryValueInput[I]()),
OptionalInput(IdleInput),
OptionalInput(TimeInput),
OptionalInput(RetryCountInput),
......@@ -348,11 +348,11 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XClaim,
Tuple10(
ArbitraryInput[SK](),
ArbitraryInput[SG](),
ArbitraryInput[SC](),
ArbitraryKeyInput[SK](),
ArbitraryValueInput[SG](),
ArbitraryValueInput[SC](),
DurationMillisecondsInput,
NonEmptyList(ArbitraryInput[I]()),
NonEmptyList(ArbitraryValueInput[I]()),
OptionalInput(IdleInput),
OptionalInput(TimeInput),
OptionalInput(RetryCountInput),
......@@ -382,7 +382,13 @@ trait Streams extends RedisEnvironment {
*/
final def xDel[SK: Schema, I: Schema](key: SK, id: I, ids: I*): IO[RedisError, Long] = {
val command =
RedisCommand(XDel, Tuple2(ArbitraryInput[SK](), NonEmptyList(ArbitraryInput[I]())), LongOutput, codec, executor)
RedisCommand(
XDel,
Tuple2(ArbitraryKeyInput[SK](), NonEmptyList(ArbitraryValueInput[I]())),
LongOutput,
codec,
executor
)
command.run((key, (id, ids.toList)))
}
......@@ -491,7 +497,7 @@ trait Streams extends RedisEnvironment {
* the number of entries inside a stream.
*/
final def xLen[SK: Schema](key: SK): IO[RedisError, Long] = {
val command = RedisCommand(XLen, ArbitraryInput[SK](), LongOutput, codec, executor)
val command = RedisCommand(XLen, ArbitraryKeyInput[SK](), LongOutput, codec, executor)
command.run(key)
}
......@@ -508,7 +514,7 @@ trait Streams extends RedisEnvironment {
final def xPending[SK: Schema, SG: Schema](key: SK, group: SG): IO[RedisError, PendingInfo] = {
val command = RedisCommand(
XPending,
Tuple3(ArbitraryInput[SK](), ArbitraryInput[SG](), OptionalInput(IdleInput)),
Tuple3(ArbitraryKeyInput[SK](), ArbitraryValueInput[SG](), OptionalInput(IdleInput)),
XPendingOutput,
codec,
executor
......@@ -548,13 +554,13 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XPending,
Tuple7(
ArbitraryInput[SK](),
ArbitraryInput[SG](),
ArbitraryKeyInput[SK](),
ArbitraryValueInput[SG](),
OptionalInput(IdleInput),
ArbitraryInput[I](),
ArbitraryInput[I](),
ArbitraryValueInput[I](),
ArbitraryValueInput[I](),
LongInput,
OptionalInput(ArbitraryInput[SC]())
OptionalInput(ArbitraryValueInput[SC]())
),
PendingMessagesOutput,
codec,
......@@ -584,7 +590,12 @@ trait Streams extends RedisEnvironment {
def returning[RK: Schema, RV: Schema]: IO[RedisError, StreamEntries[I, RK, RV]] = {
val command = RedisCommand(
XRange,
Tuple4(ArbitraryInput[SK](), ArbitraryInput[I](), ArbitraryInput[I](), OptionalInput(CountInput)),
Tuple4(
ArbitraryKeyInput[SK](),
ArbitraryValueInput[I](),
ArbitraryValueInput[I](),
OptionalInput(CountInput)
),
StreamEntriesOutput[I, RK, RV](),
codec,
executor
......@@ -617,7 +628,12 @@ trait Streams extends RedisEnvironment {
def returning[RK: Schema, RV: Schema]: IO[RedisError, StreamEntries[I, RK, RV]] = {
val command = RedisCommand(
XRange,
Tuple4(ArbitraryInput[SK](), ArbitraryInput[I](), ArbitraryInput[I](), OptionalInput(CountInput)),
Tuple4(
ArbitraryKeyInput[SK](),
ArbitraryValueInput[I](),
ArbitraryValueInput[I](),
OptionalInput(CountInput)
),
StreamEntriesOutput[I, RK, RV](),
codec,
executor
......@@ -695,8 +711,8 @@ trait Streams extends RedisEnvironment {
val command = RedisCommand(
XReadGroup,
Tuple6(
ArbitraryInput[SG](),
ArbitraryInput[SC](),
ArbitraryValueInput[SG](),
ArbitraryValueInput[SC](),
OptionalInput(CountInput),
OptionalInput(BlockInput),
OptionalInput(NoAckInput),
......@@ -732,7 +748,12 @@ trait Streams extends RedisEnvironment {
def returning[RK: Schema, RV: Schema]: IO[RedisError, StreamEntries[I, RK, RV]] = {
val command = RedisCommand(
XRevRange,
Tuple4(ArbitraryInput[SK](), ArbitraryInput[I](), ArbitraryInput[I](), OptionalInput(CountInput)),
Tuple4(
ArbitraryKeyInput[SK](),
ArbitraryValueInput[I](),
ArbitraryValueInput[I](),
OptionalInput(CountInput)
),
StreamEntriesOutput[I, RK, RV](),
codec,
executor
......@@ -765,7 +786,12 @@ trait Streams extends RedisEnvironment {
def returning[RK: Schema, RV: Schema]: IO[RedisError, StreamEntries[I, RK, RV]] = {
val command = RedisCommand(
XRevRange,
Tuple4(ArbitraryInput[SK](), ArbitraryInput[I](), ArbitraryInput[I](), OptionalInput(CountInput)),
Tuple4(
ArbitraryKeyInput[SK](),
ArbitraryValueInput[I](),
ArbitraryValueInput[I](),
OptionalInput(CountInput)
),
StreamEntriesOutput[I, RK, RV](),
codec,
executor
......@@ -791,7 +817,7 @@ trait Streams extends RedisEnvironment {
count: Long,
approximate: Boolean = false
): IO[RedisError, Long] = {
val command = RedisCommand(XTrim, Tuple2(ArbitraryInput[SK](), StreamMaxLenInput), LongOutput, codec, executor)
val command = RedisCommand(XTrim, Tuple2(ArbitraryKeyInput[SK](), StreamMaxLenInput), LongOutput, codec, executor)
command.run((key, StreamMaxLen(approximate, count)))
}
}
......
......@@ -39,7 +39,8 @@ trait Strings extends RedisEnvironment {
* Returns the length of the string after the append operation.
*/
final def append[K: Schema, V: Schema](key: K, value: V): IO[RedisError, Long] = {
val command = RedisCommand(Append, Tuple2(ArbitraryInput[K](), ArbitraryInput[V]()), LongOutput, codec, executor)
val command =
RedisCommand(Append, Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]()), LongOutput, codec, executor)
command.run((key, value))
}
......@@ -55,7 +56,7 @@ trait Strings extends RedisEnvironment {
*/
final def bitCount[K: Schema](key: K, range: Option[Range] = None): IO[RedisError, Long] = {
val command =
RedisCommand(BitCount, Tuple2(ArbitraryInput[K](), OptionalInput(RangeInput)), LongOutput, codec, executor)
RedisCommand(BitCount, Tuple2(ArbitraryKeyInput[K](), OptionalInput(RangeInput)), LongOutput, codec, executor)
command.run((key, range))
}
......@@ -78,7 +79,7 @@ trait Strings extends RedisEnvironment {
): IO[RedisError, Chunk[Option[Long]]] = {
val command = RedisCommand(
BitField,
Tuple2(ArbitraryInput[K](), NonEmptyList(BitFieldCommandInput)),
Tuple2(ArbitraryKeyInput[K](), NonEmptyList(BitFieldCommandInput)),
ChunkOutput(OptionalOutput(LongOutput)),
codec,
executor
......@@ -109,7 +110,7 @@ trait Strings extends RedisEnvironment {
val command =
RedisCommand(
BitOp,
Tuple3(BitOperationInput, ArbitraryInput[D](), NonEmptyList(ArbitraryInput[S]())),
Tuple3(BitOperationInput, ArbitraryValueInput[D](), NonEmptyList(ArbitraryValueInput[S]())),
LongOutput,
codec,
executor
......@@ -137,7 +138,7 @@ trait Strings extends RedisEnvironment {
val command =
RedisCommand(
BitPos,
Tuple3(ArbitraryInput[K](), BoolInput, OptionalInput(BitPosRangeInput)),
Tuple3(ArbitraryKeyInput[K](), BoolInput, OptionalInput(BitPosRangeInput)),
LongOutput,
codec,
executor
......@@ -154,7 +155,7 @@ trait Strings extends RedisEnvironment {
* Returns the value of key after the decrement.
*/
final def decr[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(Decr, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(Decr, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -169,7 +170,7 @@ trait Strings extends RedisEnvironment {
* Returns the value of key after the decrement.
*/
final def decrBy[K: Schema](key: K, decrement: Long): IO[RedisError, Long] = {
val command = RedisCommand(DecrBy, Tuple2(ArbitraryInput[K](), LongInput), LongOutput, codec, executor)
val command = RedisCommand(DecrBy, Tuple2(ArbitraryKeyInput[K](), LongInput), LongOutput, codec, executor)
command.run((key, decrement))
}
......@@ -184,7 +185,7 @@ trait Strings extends RedisEnvironment {
final def get[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[R: Schema]: IO[RedisError, Option[R]] =
RedisCommand(Get, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor).run(key)
RedisCommand(Get, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor).run(key)
}
/**
......@@ -198,7 +199,7 @@ trait Strings extends RedisEnvironment {
* Returns the bit value stored at offset.
*/
final def getBit[K: Schema](key: K, offset: Long): IO[RedisError, Long] = {
val command = RedisCommand(GetBit, Tuple2(ArbitraryInput[K](), LongInput), LongOutput, codec, executor)
val command = RedisCommand(GetBit, Tuple2(ArbitraryKeyInput[K](), LongInput), LongOutput, codec, executor)
command.run((key, offset))
}
......@@ -217,7 +218,7 @@ trait Strings extends RedisEnvironment {
def returning[R: Schema]: IO[RedisError, Option[R]] =
RedisCommand(
GetRange,
Tuple2(ArbitraryInput[K](), RangeInput),
Tuple2(ArbitraryKeyInput[K](), RangeInput),
OptionalOutput(ArbitraryOutput[R]()),
codec,
executor
......@@ -240,7 +241,7 @@ trait Strings extends RedisEnvironment {
def returning[R: Schema]: IO[RedisError, Option[R]] =
RedisCommand(
GetSet,
Tuple2(ArbitraryInput[K](), ArbitraryInput[V]()),
Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]()),
OptionalOutput(ArbitraryOutput[R]()),
codec,
executor
......@@ -259,7 +260,7 @@ trait Strings extends RedisEnvironment {
final def getDel[K: Schema](key: K): ResultBuilder1[Option] =
new ResultBuilder1[Option] {
def returning[R: Schema]: IO[RedisError, Option[R]] =
RedisCommand(GetDel, ArbitraryInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor).run(key)
RedisCommand(GetDel, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[R]()), codec, executor).run(key)
}
/**
......@@ -328,7 +329,7 @@ trait Strings extends RedisEnvironment {
* Returns the value of key after the increment.
*/
final def incr[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(Incr, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(Incr, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -344,7 +345,7 @@ trait Strings extends RedisEnvironment {
*/
final def incrBy[K: Schema](key: K, increment: Long): IO[RedisError, Long] = {
val command =
RedisCommand(IncrBy, Tuple2(ArbitraryInput[K](), LongInput), LongOutput, codec, executor)
RedisCommand(IncrBy, Tuple2(ArbitraryKeyInput[K](), LongInput), LongOutput, codec, executor)
command.run((key, increment))
}
......@@ -359,7 +360,7 @@ trait Strings extends RedisEnvironment {
* Returns the value of key after the increment.
*/
final def incrByFloat[K: Schema](key: K, increment: Double): IO[RedisError, Double] = {
val command = RedisCommand(IncrByFloat, Tuple2(ArbitraryInput[K](), DoubleInput), DoubleOutput, codec, executor)
val command = RedisCommand(IncrByFloat, Tuple2(ArbitraryKeyInput[K](), DoubleInput), DoubleOutput, codec, executor)
command.run((key, increment))
}
......@@ -382,7 +383,7 @@ trait Strings extends RedisEnvironment {
val command =
RedisCommand(
MGet,
NonEmptyList(ArbitraryInput[K]()),
NonEmptyList(ArbitraryKeyInput[K]()),
ChunkOutput(OptionalOutput(ArbitraryOutput[V]())),
codec,
executor
......@@ -401,7 +402,13 @@ trait Strings extends RedisEnvironment {
*/
final def mSet[K: Schema, V: Schema](keyValue: (K, V), keyValues: (K, V)*): IO[RedisError, Unit] = {
val command =
RedisCommand(MSet, NonEmptyList(Tuple2(ArbitraryInput[K](), ArbitraryInput[V]())), UnitOutput, codec, executor)
RedisCommand(
MSet,
NonEmptyList(Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]())),
UnitOutput,
codec,
executor
)
command.run((keyValue, keyValues.toList))
}
......@@ -420,7 +427,13 @@ trait Strings extends RedisEnvironment {
keyValues: (K, V)*
): IO[RedisError, Boolean] = {
val command =
RedisCommand(MSetNx, NonEmptyList(Tuple2(ArbitraryInput[K](), ArbitraryInput[V]())), BoolOutput, codec, executor)
RedisCommand(
MSetNx,
NonEmptyList(Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]())),
BoolOutput,
codec,
executor
)
command.run((keyValue, keyValues.toList))
}
......@@ -442,7 +455,7 @@ trait Strings extends RedisEnvironment {
val command =
RedisCommand(
PSetEx,
Tuple3(ArbitraryInput[K](), DurationMillisecondsInput, ArbitraryInput[V]()),
Tuple3(ArbitraryKeyInput[K](), DurationMillisecondsInput, ArbitraryValueInput[V]()),
UnitOutput,
codec,
executor
......@@ -475,8 +488,8 @@ trait Strings extends RedisEnvironment {
keepTtl: Option[KeepTtl] = None
): IO[RedisError, Boolean] = {
val input = Tuple5(
ArbitraryInput[K](),
ArbitraryInput[V](),
ArbitraryKeyInput[K](),
ArbitraryValueInput[V](),
OptionalInput(DurationTtlInput),
OptionalInput(UpdateInput),
OptionalInput(KeepTtlInput)
......@@ -498,7 +511,8 @@ trait Strings extends RedisEnvironment {
* Returns the original bit value stored at offset.
*/
final def setBit[K: Schema](key: K, offset: Long, value: Boolean): IO[RedisError, Boolean] = {
val command = RedisCommand(SetBit, Tuple3(ArbitraryInput[K](), LongInput, BoolInput), BoolOutput, codec, executor)
val command =
RedisCommand(SetBit, Tuple3(ArbitraryKeyInput[K](), LongInput, BoolInput), BoolOutput, codec, executor)
command.run((key, offset, value))
}
......@@ -520,7 +534,7 @@ trait Strings extends RedisEnvironment {
val command =
RedisCommand(
SetEx,
Tuple3(ArbitraryInput[K](), DurationSecondsInput, ArbitraryInput[V]()),
Tuple3(ArbitraryKeyInput[K](), DurationSecondsInput, ArbitraryValueInput[V]()),
UnitOutput,
codec,
executor
......@@ -539,7 +553,8 @@ trait Strings extends RedisEnvironment {
* Returns 1 if the key was set. 0 if the key was not set.
*/
final def setNx[K: Schema, V: Schema](key: K, value: V): IO[RedisError, Boolean] = {
val command = RedisCommand(SetNx, Tuple2(ArbitraryInput[K](), ArbitraryInput[V]()), BoolOutput, codec, executor)
val command =
RedisCommand(SetNx, Tuple2(ArbitraryKeyInput[K](), ArbitraryValueInput[V]()), BoolOutput, codec, executor)
command.run((key, value))
}
......@@ -557,7 +572,13 @@ trait Strings extends RedisEnvironment {
*/
final def setRange[K: Schema, V: Schema](key: K, offset: Long, value: V): IO[RedisError, Long] = {
val command =
RedisCommand(SetRange, Tuple3(ArbitraryInput[K](), LongInput, ArbitraryInput[V]()), LongOutput, codec, executor)
RedisCommand(
SetRange,
Tuple3(ArbitraryKeyInput[K](), LongInput, ArbitraryValueInput[V]()),
LongOutput,
codec,
executor
)
command.run((key, offset, value))
}
......@@ -570,7 +591,7 @@ trait Strings extends RedisEnvironment {
* Returns the length of the string.
*/
final def strLen[K: Schema](key: K): IO[RedisError, Long] = {
val command = RedisCommand(StrLen, ArbitraryInput[K](), LongOutput, codec, executor)
val command = RedisCommand(StrLen, ArbitraryKeyInput[K](), LongOutput, codec, executor)
command.run(key)
}
......@@ -600,9 +621,9 @@ trait Strings extends RedisEnvironment {
val redisCommand = RedisCommand(
StrAlgoLcs,
Tuple4(
ArbitraryInput[String](),
ArbitraryInput[K](),
ArbitraryInput[K](),
ArbitraryValueInput[String](),
ArbitraryKeyInput[K](),
ArbitraryKeyInput[K](),
OptionalInput(StralgoLcsQueryTypeInput)
),
StrAlgoLcsOutput,
......
......@@ -44,6 +44,15 @@ trait KeysSpec extends BaseSpec {
e2 <- redis.exists("unknown")
} yield assert(e1)(equalTo(1L)) && assert(e2)(equalTo(0L))
},
test("check multiple existence") {
for {
redis <- ZIO.service[Redis]
key <- uuid
value <- uuid
_ <- redis.set(key, value)
e1 <- redis.exists(key, "unknown")
} yield assert(e1)(equalTo(1L))
} @@ clusterExecutorUnsupported,
test("delete existing key") {
for {
redis <- ZIO.service[Redis]
......@@ -53,6 +62,17 @@ trait KeysSpec extends BaseSpec {
deleted <- redis.del(key)
} yield assert(deleted)(equalTo(1L))
},
test("delete multiple existing key") {
for {
redis <- ZIO.service[Redis]
key1 <- uuid
key2 <- uuid
value <- uuid
_ <- redis.set(key1, value)
_ <- redis.set(key2, value)
deleted <- redis.del(key1, key2)
} yield assert(deleted)(equalTo(2L))
} @@ clusterExecutorUnsupported,
test("find all keys matching pattern") {
for {
redis <- ZIO.service[Redis]
......@@ -72,7 +92,7 @@ trait KeysSpec extends BaseSpec {
_ <- redis.set(key, value)
removed <- redis.unlink(key)
} yield assert(removed)(equalTo(1L))
},
} @@ clusterExecutorUnsupported,
test("touch two existing keys") {
for {
redis <- ZIO.service[Redis]
......@@ -96,7 +116,7 @@ trait KeysSpec extends BaseSpec {
(next, elements) = scan
} yield assert(next)(isGreaterThanEqualTo(0L)) && assert(elements)(isNonEmpty)
}
) @@ flaky,
) @@ flaky @@ clusterExecutorUnsupported,
test("fetch random key") {
for {
redis <- ZIO.service[Redis]
......@@ -106,7 +126,7 @@ trait KeysSpec extends BaseSpec {
allKeys <- redis.keys("*").returning[String]
randomKey <- redis.randomKey.returning[String]
} yield assert(allKeys)(contains(randomKey.get))
} @@ ignore,
} @@ ignore @@ clusterExecutorUnsupported,
test("dump followed by restore") {
for {
redis <- ZIO.service[Redis]
......
package zio.redis
import zio._
import zio.redis.Input.{BoolInput, ByteInput, LongInput, StringInput}
import zio.redis.Input.{BoolInput, LongInput, StringInput, ValueInput}
import zio.redis.Output._
import zio.redis.RedisError._
import zio.redis.ScriptingSpec._
......@@ -162,7 +162,7 @@ trait ScriptingSpec extends BaseSpec {
res <- redis.evalSha(lua, emptyInput, emptyInput).returning[String].either
} yield assert(res)(isLeft(isSubtype[NoScript](hasField("message", _.message, equalTo(error)))))
}
),
) @@ clusterExecutorUnsupported,
suite("scriptDebug")(
test("enable non-blocking asynchronous debugging") {
for {
......@@ -202,7 +202,7 @@ trait ScriptingSpec extends BaseSpec {
res <- redis.scriptExists(lua1, lua2)
} yield assertTrue(res == Chunk(false, false))
}
),
) @@ clusterExecutorUnsupported,
suite("scriptFlush")(
test("flush scripts in default mode") {
val lua1 = """return "1""""
......@@ -237,7 +237,7 @@ trait ScriptingSpec extends BaseSpec {
res <- redis.scriptExists(sha1, sha2)
} yield assertTrue(res == Chunk(false, false))
}
),
) @@ clusterExecutorUnsupported,
suite("scriptKill")(
test("return NOTBUSY when there is no scripts in execution") {
for {
......@@ -245,7 +245,7 @@ trait ScriptingSpec extends BaseSpec {
res <- redis.scriptKill.either
} yield assert(res)(isLeft(isSubtype[RedisError.NotBusy](anything)))
}
),
) @@ clusterExecutorUnsupported,
suite("scriptLoad")(
test("return OK") {
val lua = """return "1""""
......@@ -262,7 +262,7 @@ trait ScriptingSpec extends BaseSpec {
sha <- redis.scriptLoad(lua).either
} yield assert(sha)(isLeft(isSubtype[ProtocolError](hasField("message", _.message, equalTo(error)))))
}
)
) @@ clusterExecutorUnsupported
)
}
......@@ -301,7 +301,7 @@ object ScriptingSpec {
case other => throw ProtocolError(s"$other isn't a string type")
}
implicit val bytesEncoder: Input[Chunk[Byte]] = ByteInput
implicit val bytesEncoder: Input[Chunk[Byte]] = ValueInput
implicit val booleanInput: Input[Boolean] = BoolInput
implicit val stringInput: Input[String] = StringInput
implicit val longInput: Input[Long] = LongInput
......
......@@ -3,7 +3,7 @@ package zio.redis
import zio._
import zio.redis.RedisError._
import zio.test.Assertion._
import zio.test.TestAspect.ignore
import zio.test.TestAspect.{flaky, ignore}
import zio.test._
trait StreamsSpec extends BaseSpec {
......@@ -926,7 +926,7 @@ trait StreamsSpec extends BaseSpec {
assert(result.owner)(equalTo(consumer)) &&
assert(result.lastDelivered)(isGreaterThan(0.millis)) &&
assert(result.counter)(equalTo(1L))
},
} @@ flaky,
test("with multiple message, unlimited start, unlimited end and count with value 10") {
for {
redis <- ZIO.service[Redis]
......@@ -950,7 +950,7 @@ trait StreamsSpec extends BaseSpec {
assert(secondResult.owner)(equalTo(second)) &&
assert(secondResult.lastDelivered)(isGreaterThan(0.millis)) &&
assert(secondResult.counter)(equalTo(1L))
},
} @@ flaky,
test("with unlimited start, unlimited end, count with value 10, and the specified consumer") {
for {
redis <- ZIO.service[Redis]
......@@ -1078,7 +1078,7 @@ trait StreamsSpec extends BaseSpec {
)
)
)
},
} @@ clusterExecutorUnsupported,
test("with the positive count") {
for {
redis <- ZIO.service[Redis]
......@@ -1226,7 +1226,7 @@ trait StreamsSpec extends BaseSpec {
)
)
)
},
} @@ clusterExecutorUnsupported,
test("with positive count") {
for {
redis <- ZIO.service[Redis]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册