未验证 提交 ad41feca 编写于 作者: L Landlocked Surfer 提交者: GitHub

Add missing strings commands (#21)

上级 c0f6f91b
......@@ -10,33 +10,43 @@ import scala.util.matching.Regex
sealed trait Input[-A]
object Input {
case object ByteInput extends Input[Chunk[Byte]]
case object DoubleInput extends Input[Double]
case object DurationInput extends Input[Duration]
case object LongInput extends Input[Long]
case object MatchInput extends Input[Regex]
case object UnitInput extends Input[Unit]
case object RangeInput extends Input[Range]
case object StringInput extends Input[String]
case object TimeInput extends Input[Instant]
case object SortedSetMemberScoreInput extends Input[options.MemberScore]
case object SortedSetUpdateInput extends Input[options.Updates]
case object SortedSetChangedInput extends Input[options.CH]
case object SortedSetIncrementInput extends Input[options.INCR]
case object SortedSetAggregateInput extends Input[options.Aggregate]
case object SortedSetLexRangeInput extends Input[options.LexRange]
case object SortedSetWithScoresInput extends Input[options.WithScores]
case object SortedSetLimitInput extends Input[options.Limit]
case object SortedSetScoreRangeInput extends Input[options.ScoreRange]
case object GeoCountInput extends Input[options.Count]
case object GeoLongLatInput extends Input[options.LongLat]
case object GeoOrderInput extends Input[options.Order]
case object GeoRadiusUnitInput extends Input[options.RadiusUnit]
case object GeoStoreInput extends Input[options.Store]
case object GeoStoreDistInput extends Input[options.StoreDist]
case object GeoWithCoordInput extends Input[options.WithCoord]
case object GeoWithDistInput extends Input[options.WithDist]
case object GeoWithHashInput extends Input[options.WithHash]
case object BoolInput extends Input[Boolean]
case object ByteInput extends Input[Chunk[Byte]]
case object DoubleInput extends Input[Double]
case object DurationInput extends Input[Duration]
case object LongInput extends Input[Long]
case object MatchInput extends Input[Regex]
case object UnitInput extends Input[Unit]
case object RangeInput extends Input[Range]
case object StringInput extends Input[String]
case object TimeInput extends Input[Instant]
case object SortedSetMemberScoreInput extends Input[options.MemberScore]
case object SortedSetUpdateInput extends Input[options.Updates]
case object SortedSetChangedInput extends Input[options.CH]
case object SortedSetIncrementInput extends Input[options.INCR]
case object SortedSetAggregateInput extends Input[options.Aggregate]
case object SortedSetLexRangeInput extends Input[options.LexRange]
case object SortedSetWithScoresInput extends Input[options.WithScores]
case object SortedSetLimitInput extends Input[options.Limit]
case object SortedSetScoreRangeInput extends Input[options.ScoreRange]
case object GeoCountInput extends Input[options.Count]
case object GeoLongLatInput extends Input[options.LongLat]
case object GeoOrderInput extends Input[options.Order]
case object GeoRadiusUnitInput extends Input[options.RadiusUnit]
case object GeoStoreInput extends Input[options.Store]
case object GeoStoreDistInput extends Input[options.StoreDist]
case object GeoWithCoordInput extends Input[options.WithCoord]
case object GeoWithDistInput extends Input[options.WithDist]
case object GeoWithHashInput extends Input[options.WithHash]
case object StringBitFieldGetInput extends Input[options.BitFieldGet]
case object StringBitFieldSetInput extends Input[options.BitFieldSet]
case object StringBitFieldIncrInput extends Input[options.BitFieldIncr]
case object StringBitFieldOverflowInput extends Input[options.BitFieldOverflow]
case object StringBitOperationInput extends Input[options.BitOperation]
case object StringBitPosRangeInput extends Input[options.BitPosRange]
case object StringExpirationInput extends Input[options.Expiration]
case object StringKeepTimeToLiveInput extends Input[options.KEEPTTL]
case object UpdatesInput extends Input[options.Updates]
final case class OptionalInput[-A](a: Input[A]) extends Input[Option[A]]
......
......@@ -12,7 +12,7 @@ trait SortedSets {
"ZADD",
Tuple5(
StringInput,
OptionalInput(SortedSetUpdateInput),
OptionalInput(UpdatesInput),
OptionalInput(SortedSetChangedInput),
OptionalInput(SortedSetIncrementInput),
NonEmptyList(SortedSetMemberScoreInput)
......
......@@ -5,8 +5,31 @@ import zio.redis.Input._
import zio.redis.Output._
trait Strings {
final val append = Command("APPEND", Tuple2(StringInput, ByteInput), LongOutput)
final val bitcount = Command("BITCOUNT", Tuple2(StringInput, OptionalInput(RangeInput)), LongOutput)
final val append = Command("APPEND", Tuple2(StringInput, ByteInput), LongOutput)
final val bitcount = Command("BITCOUNT", Tuple2(StringInput, OptionalInput(RangeInput)), LongOutput)
final val bitfield = Command(
"BITFIELD",
Tuple5(
StringInput,
OptionalInput(NonEmptyList(StringBitFieldGetInput)),
OptionalInput(NonEmptyList(StringBitFieldSetInput)),
OptionalInput(NonEmptyList(StringBitFieldIncrInput)),
OptionalInput(NonEmptyList(StringBitFieldOverflowInput))
),
StreamOutput
)
final val bitop =
Command(
"BITOP",
Tuple3(
StringBitOperationInput,
StringInput,
NonEmptyList(StringInput)
),
LongOutput
)
final val bitpos =
Command("BITPOS", Tuple3(StringInput, BoolInput, OptionalInput(StringBitPosRangeInput)), LongOutput)
final val decr = Command("DECR", StringInput, LongOutput)
final val decrby = Command("DECRBY", Tuple2(StringInput, LongInput), LongOutput)
final val get = Command("GET", StringInput, ByteOutput)
......@@ -20,9 +43,20 @@ trait Strings {
final val mset = Command("MSET", NonEmptyList(Tuple2(StringInput, ByteInput)), UnitOutput)
final val msetnx = Command("MSETNX", NonEmptyList(Tuple2(StringInput, ByteInput)), BoolOutput)
final val psetex = Command("PSETEX", Tuple3(StringInput, DurationInput, ByteInput), UnitOutput)
final val setbit = Command("SETBIT", Tuple3(StringInput, LongInput, ByteInput), ByteOutput)
final val setex = Command("SETEX", Tuple3(StringInput, DurationInput, ByteInput), UnitOutput)
final val setnx = Command("SETNX", Tuple2(StringInput, ByteInput), BoolOutput)
final val setrange = Command("SETRANGE", Tuple3(StringInput, LongInput, ByteInput), LongOutput)
final val strlen = Command("STRLEN", StringInput, LongOutput)
final val set = Command(
"SET",
Tuple5(
StringInput,
ByteInput,
OptionalInput(StringExpirationInput),
OptionalInput(UpdatesInput),
OptionalInput(StringKeepTimeToLiveInput)
),
OptionalOutput(UnitOutput)
)
final val setbit = Command("SETBIT", Tuple3(StringInput, LongInput, ByteInput), ByteOutput)
final val setex = Command("SETEX", Tuple3(StringInput, DurationInput, ByteInput), UnitOutput)
final val setnx = Command("SETNX", Tuple2(StringInput, ByteInput), BoolOutput)
final val setrange = Command("SETRANGE", Tuple3(StringInput, LongInput, ByteInput), LongOutput)
final val strlen = Command("STRLEN", StringInput, LongOutput)
}
package zio.redis.options
trait Shared {
sealed trait Updates
object Updates {
case object XX extends Updates
case object NX extends Updates
}
}
......@@ -46,13 +46,6 @@ trait SortedSets {
case object WithScores
type WithScores = WithScores.type
sealed trait Updates
object Updates {
case object XX extends Updates
case object NX extends Updates
}
case object CH
type CH = CH.type
case object INCR
......
package zio.redis.options
trait Strings {
sealed trait BitFieldType
object BitFieldType {
sealed case class UnsignedInt(size: Int) extends BitFieldType
sealed case class SignedInt(size: Int) extends BitFieldType
}
case class BitFieldGet(`type`: BitFieldType, offset: Int)
case class BitFieldSet(`type`: BitFieldType, offset: Int, value: BigInt)
case class BitFieldIncr(`type`: BitFieldType, offset: Int, increment: BigInt)
sealed trait BitFieldOverflow
object BitFieldOverflow {
case object FAIL extends BitFieldOverflow
case object SAT extends BitFieldOverflow
case object WRAP extends BitFieldOverflow
}
sealed trait BitOperation
object BitOperation {
case object AND extends BitOperation
case object OR extends BitOperation
case object XOR extends BitOperation
}
case class BitPosRange(start: Long, end: Option[Long])
sealed trait Expiration
object Expiration {
sealed case class EX(seconds: Long) extends Expiration
sealed case class PX(milliSeconds: Long) extends Expiration
}
case object KEEPTTL
type KEEPTTL = KEEPTTL.type
}
package zio.redis
package object options extends SortedSets with Geo {
// common options
}
package object options extends Geo with Shared with SortedSets with Strings
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册