Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Zio Redis
提交
fc43d270
Z
Zio Redis
项目概览
梦境迷离
/
Zio Redis
9 个月 前同步成功
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
Zio Redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
fc43d270
编写于
2月 25, 2023
作者:
A
Anatoly Sergeev
提交者:
GitHub
2月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add resp command in order to distinguish resp types (#763)
上级
f863f6c7
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
1057 addition
and
704 deletion
+1057
-704
redis/src/main/scala/zio/redis/ClusterExecutor.scala
redis/src/main/scala/zio/redis/ClusterExecutor.scala
+2
-2
redis/src/main/scala/zio/redis/Input.scala
redis/src/main/scala/zio/redis/Input.scala
+272
-222
redis/src/main/scala/zio/redis/RedisCommand.scala
redis/src/main/scala/zio/redis/RedisCommand.scala
+3
-3
redis/src/main/scala/zio/redis/RedisExecutor.scala
redis/src/main/scala/zio/redis/RedisExecutor.scala
+2
-2
redis/src/main/scala/zio/redis/RespArgument.scala
redis/src/main/scala/zio/redis/RespArgument.scala
+64
-0
redis/src/main/scala/zio/redis/RespCommand.scala
redis/src/main/scala/zio/redis/RespCommand.scala
+36
-0
redis/src/main/scala/zio/redis/SingleNodeExecutor.scala
redis/src/main/scala/zio/redis/SingleNodeExecutor.scala
+2
-2
redis/src/main/scala/zio/redis/api/Cluster.scala
redis/src/main/scala/zio/redis/api/Cluster.scala
+4
-4
redis/src/main/scala/zio/redis/api/Geo.scala
redis/src/main/scala/zio/redis/api/Geo.scala
+21
-10
redis/src/main/scala/zio/redis/api/Hashes.scala
redis/src/main/scala/zio/redis/api/Hashes.scala
+31
-17
redis/src/main/scala/zio/redis/api/HyperLogLog.scala
redis/src/main/scala/zio/redis/api/HyperLogLog.scala
+15
-3
redis/src/main/scala/zio/redis/api/Keys.scala
redis/src/main/scala/zio/redis/api/Keys.scala
+25
-22
redis/src/main/scala/zio/redis/api/Lists.scala
redis/src/main/scala/zio/redis/api/Lists.scala
+54
-23
redis/src/main/scala/zio/redis/api/Sets.scala
redis/src/main/scala/zio/redis/api/Sets.scala
+28
-15
redis/src/main/scala/zio/redis/api/SortedSets.scala
redis/src/main/scala/zio/redis/api/SortedSets.scala
+89
-55
redis/src/main/scala/zio/redis/api/Streams.scala
redis/src/main/scala/zio/redis/api/Streams.scala
+61
-35
redis/src/main/scala/zio/redis/api/Strings.scala
redis/src/main/scala/zio/redis/api/Strings.scala
+50
-29
redis/src/test/scala/zio/redis/InputSpec.scala
redis/src/test/scala/zio/redis/InputSpec.scala
+263
-245
redis/src/test/scala/zio/redis/KeysSpec.scala
redis/src/test/scala/zio/redis/KeysSpec.scala
+23
-3
redis/src/test/scala/zio/redis/ScriptingSpec.scala
redis/src/test/scala/zio/redis/ScriptingSpec.scala
+7
-7
redis/src/test/scala/zio/redis/StreamsSpec.scala
redis/src/test/scala/zio/redis/StreamsSpec.scala
+5
-5
未找到文件。
redis/src/main/scala/zio/redis/ClusterExecutor.scala
浏览文件 @
fc43d270
...
...
@@ -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
...
...
redis/src/main/scala/zio/redis/Input.scala
浏览文件 @
fc43d270
此差异已折叠。
点击以展开。
redis/src/main/scala/zio/redis/RedisCommand.scala
浏览文件 @
fc43d270
...
...
@@ -17,7 +17,7 @@
package
zio.redis
import
zio._
import
zio.redis.Input.
{
String
Input
,
Varargs
}
import
zio.redis.Input.
{
CommandName
Input
,
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
(
String
Input
).
encode
(
name
.
split
(
" "
))(
codec
)
++
input
.
encode
(
in
)(
codec
)
private
[
redis
]
def
resp
(
in
:
In
)
:
RespCommand
=
Varargs
(
CommandName
Input
).
encode
(
name
.
split
(
" "
))(
codec
)
++
input
.
encode
(
in
)(
codec
)
}
object
RedisCommand
{
...
...
redis/src/main/scala/zio/redis/RedisExecutor.scala
浏览文件 @
fc43d270
...
...
@@ -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
{
...
...
redis/src/main/scala/zio/redis/RespArgument.scala
0 → 100644
浏览文件 @
fc43d270
/*
* 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
))
}
}
redis/src/main/scala/zio/redis/RespCommand.scala
0 → 100644
浏览文件 @
fc43d270
/*
* 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
))
}
redis/src/main/scala/zio/redis/SingleNodeExecutor.scala
浏览文件 @
fc43d270
...
...
@@ -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
...
...
redis/src/main/scala/zio/redis/api/Cluster.scala
浏览文件 @
fc43d270
...
...
@@ -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
,
Arbitrary
Value
Input
[
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
,
Arbitrary
Input
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
LongInput
,
Arbitrary
ValueInput
[
String
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Input
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
LongInput
,
Arbitrary
ValueInput
[
String
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Input
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
LongInput
,
Arbitrary
ValueInput
[
String
](),
ArbitraryValue
Input
[
String
]()),
UnitOutput
,
codec
,
executor
...
...
redis/src/main/scala/zio/redis/api/Geo.scala
浏览文件 @
fc43d270
...
...
@@ -44,7 +44,7 @@ trait Geo extends RedisEnvironment {
)
:
IO
[
RedisError
,
Long
]
=
{
val
command
=
RedisCommand
(
GeoAdd
,
Tuple2
(
Arbitrary
Input
[
K
](),
NonEmptyList
(
Tuple2
(
LongLatInput
,
Arbitrary
Input
[
M
]()))),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
NonEmptyList
(
Tuple2
(
LongLatInput
,
ArbitraryValue
Input
[
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
(
Arbitrary
Input
[
K
](),
NonEmptyList
(
Arbitrary
Input
[
M
]())),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
NonEmptyList
(
ArbitraryValue
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
LongLatInput
,
DoubleInput
,
RadiusUnitInput
,
...
...
@@ -235,7 +246,7 @@ trait Geo extends RedisEnvironment {
val
command
=
RedisCommand
(
GeoRadius
,
Tuple11
(
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
K
](),
LongLatInput
,
DoubleInput
,
RadiusUnitInput
,
...
...
@@ -295,8 +306,8 @@ trait Geo extends RedisEnvironment {
val
command
=
RedisCommand
(
GeoRadiusByMember
,
Tuple9
(
ArbitraryInput
[
K
](),
ArbitraryInput
[
M
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
M
](),
DoubleInput
,
RadiusUnitInput
,
OptionalInput
(
WithCoordInput
),
...
...
@@ -358,8 +369,8 @@ trait Geo extends RedisEnvironment {
val
command
=
RedisCommand
(
GeoRadiusByMember
,
Tuple11
(
ArbitraryInput
[
K
](),
ArbitraryInput
[
M
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
M
](),
DoubleInput
,
RadiusUnitInput
,
OptionalInput
(
WithCoordInput
),
...
...
redis/src/main/scala/zio/redis/api/Hashes.scala
浏览文件 @
fc43d270
...
...
@@ -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
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
F
]()),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
F
]()),
OptionalOutput
(
ArbitraryOutput
[
V
]()),
codec
,
executor
...
...
@@ -95,7 +102,7 @@ trait Hashes extends RedisEnvironment {
val
command
=
RedisCommand
(
HGetAll
,
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
F
](),
DoubleInput
),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
NonEmptyList
(
Arbitrary
Input
[
F
]())),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
NonEmptyList
(
ArbitraryValue
Input
[
F
]())),
ChunkOutput
(
OptionalOutput
(
ArbitraryOutput
[
V
]())),
codec
,
executor
...
...
@@ -229,7 +242,7 @@ trait Hashes extends RedisEnvironment {
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
HmSet
,
Tuple2
(
Arbitrary
Input
[
K
](),
NonEmptyList
(
Tuple2
(
ArbitraryInput
[
F
](),
Arbitrary
Input
[
V
]()))),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
NonEmptyList
(
Tuple2
(
ArbitraryValueInput
[
F
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
NonEmptyList
(
Tuple2
(
ArbitraryInput
[
F
](),
Arbitrary
Input
[
V
]()))),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
NonEmptyList
(
Tuple2
(
ArbitraryValueInput
[
F
](),
ArbitraryValue
Input
[
V
]()))),
LongOutput
,
codec
,
executor
...
...
@@ -317,7 +330,7 @@ trait Hashes extends RedisEnvironment {
val
command
=
RedisCommand
(
HSetNx
,
Tuple3
(
Arbitrary
Input
[
K
](),
ArbitraryInput
[
F
](),
Arbitrary
Input
[
V
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValueInput
[
F
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
](),
LongInput
,
OptionalInput
(
StringInput
)),
ChunkOutput
(
ArbitraryOutput
[
V
]()),
codec
,
executor
...
...
redis/src/main/scala/zio/redis/api/HyperLogLog.scala
浏览文件 @
fc43d270
...
...
@@ -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
(
Arbitrary
Key
Input
[
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
)))
}
}
...
...
redis/src/main/scala/zio/redis/api/Keys.scala
浏览文件 @
fc43d270
...
...
@@ -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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
](),
TimeSecondsInput
),
BoolOutput
,
codec
,
executor
)
command
.
run
((
key
,
timestamp
))
}
...
...
@@ -166,13 +167,13 @@ trait Keys extends RedisEnvironment {
Tuple9
(
StringInput
,
LongInput
,
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
K
](),
LongInput
,
LongInput
,
OptionalInput
(
CopyInput
),
OptionalInput
(
ReplaceInput
),
OptionalInput
(
AuthInput
),
OptionalInput
(
NonEmptyList
(
ArbitraryInput
[
K
]()))
OptionalInput
(
NonEmptyList
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
LongInput
,
Byt
eInput
,
Valu
eInput
,
OptionalInput
(
ReplaceInput
),
OptionalInput
(
AbsTtlInput
),
OptionalInput
(
IdleTimeInput
),
...
...
@@ -418,7 +421,7 @@ trait Keys extends RedisEnvironment {
val
command
=
RedisCommand
(
Sort
,
Tuple6
(
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
K
](),
OptionalInput
(
ByInput
),
OptionalInput
(
LimitInput
),
OptionalInput
(
NonEmptyList
(
GetInput
)),
...
...
@@ -469,7 +472,7 @@ trait Keys extends RedisEnvironment {
val
command
=
RedisCommand
(
SortStore
,
Tuple7
(
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
]()),
LongOutput
,
codec
,
executor
)
command
.
run
((
key
,
keys
.
toList
))
}
...
...
redis/src/main/scala/zio/redis/api/Lists.scala
浏览文件 @
fc43d270
...
...
@@ -49,7 +49,7 @@ trait Lists extends RedisEnvironment {
def
returning
[
V:
Schema
]
:
IO
[
RedisError
,
Option
[
V
]]
=
{
val
command
=
RedisCommand
(
BrPopLPush
,
Tuple3
(
Arbitrary
Input
[
S
](),
Arbitrary
Input
[
D
](),
DurationSecondsInput
),
Tuple3
(
Arbitrary
ValueInput
[
S
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
S
](),
Arbitrary
Input
[
D
]()),
Tuple2
(
Arbitrary
ValueInput
[
S
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
PositionInput
,
ArbitraryInput
[
V
](),
Arbitrary
Input
[
V
]()),
Tuple4
(
Arbitrary
KeyInput
[
K
](),
PositionInput
,
ArbitraryValueInput
[
V
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Input
[
S
](),
Arbitrary
Input
[
D
](),
SideInput
,
SideInput
),
Tuple4
(
Arbitrary
ValueInput
[
S
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Input
[
S
](),
Arbitrary
Input
[
D
](),
SideInput
,
SideInput
,
DurationSecondsInput
),
Tuple5
(
Arbitrary
ValueInput
[
S
](),
ArbitraryValue
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
V
](),
OptionalInput
(
RankInput
),
OptionalInput
(
ListMaxLenInput
)
),
...
...
@@ -538,8 +569,8 @@ trait Lists extends RedisEnvironment {
val
command
=
RedisCommand
(
LPos
,
Tuple5
(
ArbitraryInput
[
K
](),
ArbitraryInput
[
V
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
V
](),
CountInput
,
OptionalInput
(
RankInput
),
OptionalInput
(
ListMaxLenInput
)
...
...
redis/src/main/scala/zio/redis/api/Sets.scala
浏览文件 @
fc43d270
...
...
@@ -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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
D
](),
NonEmptyList
(
Arbitrar
yInput
[
K
]())),
Tuple2
(
Arbitrary
ValueInput
[
D
](),
NonEmptyList
(
ArbitraryKe
yInput
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
D
](),
NonEmptyList
(
Arbitrar
yInput
[
K
]())),
Tuple2
(
Arbitrary
ValueInput
[
D
](),
NonEmptyList
(
ArbitraryKe
yInput
[
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
,
Arbitrary
Key
Input
[
K
](),
ChunkOutput
(
ArbitraryOutput
[
R
]()),
codec
,
executor
).
run
(
key
)
}
/**
...
...
@@ -191,7 +198,7 @@ trait Sets extends RedisEnvironment {
)
:
IO
[
RedisError
,
Boolean
]
=
{
val
command
=
RedisCommand
(
SMove
,
Tuple3
(
Arbitrary
Input
[
S
](),
ArbitraryInput
[
D
](),
Arbitrary
Input
[
M
]()),
Tuple3
(
Arbitrary
ValueInput
[
S
](),
ArbitraryValueInput
[
D
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
D
](),
NonEmptyList
(
Arbitrar
yInput
[
K
]())),
Tuple2
(
Arbitrary
ValueInput
[
D
](),
NonEmptyList
(
ArbitraryKe
yInput
[
K
]())),
LongOutput
,
codec
,
executor
...
...
redis/src/main/scala/zio/redis/api/SortedSets.scala
浏览文件 @
fc43d270
...
...
@@ -53,7 +53,7 @@ trait SortedSets extends RedisEnvironment {
}
val
command
=
RedisCommand
(
BzPopMax
,
Tuple2
(
NonEmptyList
(
ArbitraryInput
[
K
]()),
DurationSecondsInput
),
Tuple2
(
NonEmptyList
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
]()),
DurationSecondsInput
),
OptionalOutput
(
memberScoreOutput
),
codec
,
executor
...
...
@@ -122,7 +122,7 @@ trait SortedSets extends RedisEnvironment {
val
command
=
RedisCommand
(
ZAdd
,
Tuple4
(
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
K
](),
OptionalInput
(
UpdateInput
),
OptionalInput
(
ChangedInput
),
NonEmptyList
(
MemberScoreInput
[
M
]())
...
...
@@ -161,7 +161,7 @@ trait SortedSets extends RedisEnvironment {
val
command
=
RedisCommand
(
ZAdd
,
Tuple5
(
ArbitraryInput
[
K
](),
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
](),
RangeInput
),
LongOutput
,
codec
,
executor
)
command
.
run
((
key
,
range
))
}
...
...
@@ -226,7 +226,7 @@ trait SortedSets extends RedisEnvironment {
ZDiff
,
Tuple2
(
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]())
NonEmptyList
(
Arbitrary
Key
Input
[
K
]())
),
ChunkOutput
(
ArbitraryOutput
[
M
]()),
codec
,
...
...
@@ -260,8 +260,8 @@ trait SortedSets extends RedisEnvironment {
ZDiff
,
Tuple3
(
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
ArbitraryInput
[
String
]()
NonEmptyList
(
Arbitrary
Key
Input
[
K
]()),
Arbitrary
Value
Input
[
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
](),
Arbitrary
Value
Input
[
DK
](),
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]())
NonEmptyList
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
]()),
OptionalInput
(
AggregateInput
),
OptionalInput
(
WeightsInput
)
),
...
...
@@ -397,10 +403,10 @@ trait SortedSets extends RedisEnvironment {
ZInter
,
Tuple5
(
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
NonEmptyList
(
Arbitrary
Key
Input
[
K
]()),
OptionalInput
(
AggregateInput
),
OptionalInput
(
WeightsInput
),
ArbitraryInput
[
String
]()
Arbitrary
Value
Input
[
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
](),
Arbitrary
Value
Input
[
DK
](),
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
NonEmptyList
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
ArbitraryInput
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValueInput
[
String
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
RangeInput
,
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
RangeInput
,
ArbitraryValue
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Value
Input
[
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
(
Arbitrary
Input
[
K
](),
ArbitraryInput
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValueInput
[
String
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
ArbitraryInput
[
String
](),
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValueInput
[
String
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
RangeInput
,
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
RangeInput
,
ArbitraryValue
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Value
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Value
Input
[
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
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
M
]()),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
M
]()),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
M
]()),
OptionalOutput
(
DoubleOutput
),
codec
,
executor
...
...
@@ -1042,7 +1075,7 @@ trait SortedSets extends RedisEnvironment {
ZUnion
,
Tuple4
(
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
NonEmptyList
(
Arbitrary
Key
Input
[
K
]()),
OptionalInput
(
WeightsInput
),
OptionalInput
(
AggregateInput
)
),
...
...
@@ -1083,10 +1116,10 @@ trait SortedSets extends RedisEnvironment {
ZUnion
,
Tuple5
(
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
NonEmptyList
(
Arbitrary
Key
Input
[
K
]()),
OptionalInput
(
WeightsInput
),
OptionalInput
(
AggregateInput
),
ArbitraryInput
[
String
]()
Arbitrary
Value
Input
[
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
](),
Arbitrary
Value
Input
[
DK
](),
LongInput
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
NonEmptyList
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
LongInput
,
Arbitrary
Input
[
String
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
LongInput
,
ArbitraryValue
Input
[
String
]()),
ZRandMemberTuple2Output
(
ArbitraryOutput
[
M
](),
DoubleOutput
)
.
map
(
_
.
map
{
case
(
m
,
s
)
=>
MemberScore
(
s
,
m
)
}),
codec
,
...
...
redis/src/main/scala/zio/redis/api/Streams.scala
浏览文件 @
fc43d270
...
...
@@ -50,7 +50,7 @@ trait Streams extends RedisEnvironment {
)
:
IO
[
RedisError
,
Long
]
=
{
val
command
=
RedisCommand
(
XAck
,
Tuple3
(
Arbitrary
Input
[
SK
](),
ArbitraryInput
[
G
](),
NonEmptyList
(
Arbitrary
Input
[
I
]())),
Tuple3
(
Arbitrary
KeyInput
[
SK
](),
ArbitraryValueInput
[
G
](),
NonEmptyList
(
ArbitraryValue
Input
[
I
]())),
LongOutput
,
codec
,
executor
...
...
@@ -83,10 +83,10 @@ trait Streams extends RedisEnvironment {
val
command
=
RedisCommand
(
XAdd
,
Tuple4
(
ArbitraryInput
[
SK
](),
Arbitrary
Key
Input
[
SK
](),
OptionalInput
(
StreamMaxLenInput
),
ArbitraryInput
[
I
](),
NonEmptyList
(
Tuple2
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
V
]()))
Arbitrary
Value
Input
[
I
](),
NonEmptyList
(
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
SK
](),
Arbitrary
Input
[
String
]()),
Tuple2
(
Arbitrary
KeyInput
[
SK
](),
ArbitraryValue
Input
[
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
(
Arbitrary
Input
[
SK
](),
Arbitrary
Input
[
String
](),
CountInput
),
Tuple3
(
Arbitrary
KeyInput
[
SK
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
SK
](),
StreamGroupsInfoOutput
,
codec
,
executor
)
command
.
run
(
key
)
}
...
...
@@ -192,7 +192,7 @@ trait Streams extends RedisEnvironment {
val
command
=
RedisCommand
(
XInfoConsumers
,
Tuple2
(
Arbitrary
Input
[
SK
](),
Arbitrary
Input
[
SG
]()),
Tuple2
(
Arbitrary
KeyInput
[
SK
](),
ArbitraryValue
Input
[
SG
]()),
StreamConsumersInfoOutput
,
codec
,
executor
...
...
@@ -232,10 +232,10 @@ trait Streams extends RedisEnvironment {
val
command
=
RedisCommand
(
XAdd
,
Tuple4
(
ArbitraryInput
[
SK
](),
Arbitrary
Key
Input
[
SK
](),
OptionalInput
(
StreamMaxLenInput
),
ArbitraryInput
[
I
](),
NonEmptyList
(
Tuple2
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
V
]()))
Arbitrary
Value
Input
[
I
](),
NonEmptyList
(
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
V
]()))
),
ArbitraryOutput
[
R
](),
codec
,
...
...
@@ -287,11 +287,11 @@ trait Streams extends RedisEnvironment {
val
command
=
RedisCommand
(
XClaim
,
Tuple9
(
ArbitraryInput
[
SK
](),
ArbitraryInput
[
SG
](),
ArbitraryInput
[
SC
](),
Arbitrary
Key
Input
[
SK
](),
Arbitrary
Value
Input
[
SG
](),
Arbitrary
Value
Input
[
SC
](),
DurationMillisecondsInput
,
NonEmptyList
(
ArbitraryInput
[
I
]()),
NonEmptyList
(
Arbitrary
Value
Input
[
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
](),
Arbitrary
Key
Input
[
SK
](),
Arbitrary
Value
Input
[
SG
](),
Arbitrary
Value
Input
[
SC
](),
DurationMillisecondsInput
,
NonEmptyList
(
ArbitraryInput
[
I
]()),
NonEmptyList
(
Arbitrary
Value
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
SK
](),
Arbitrary
Input
[
SG
](),
OptionalInput
(
IdleInput
)),
Tuple3
(
Arbitrary
KeyInput
[
SK
](),
ArbitraryValue
Input
[
SG
](),
OptionalInput
(
IdleInput
)),
XPendingOutput
,
codec
,
executor
...
...
@@ -548,13 +554,13 @@ trait Streams extends RedisEnvironment {
val
command
=
RedisCommand
(
XPending
,
Tuple7
(
ArbitraryInput
[
SK
](),
ArbitraryInput
[
SG
](),
Arbitrary
Key
Input
[
SK
](),
Arbitrary
Value
Input
[
SG
](),
OptionalInput
(
IdleInput
),
ArbitraryInput
[
I
](),
ArbitraryInput
[
I
](),
Arbitrary
Value
Input
[
I
](),
Arbitrary
Value
Input
[
I
](),
LongInput
,
OptionalInput
(
ArbitraryInput
[
SC
]())
OptionalInput
(
Arbitrary
Value
Input
[
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
](),
Arbitrary
Value
Input
[
SG
](),
Arbitrary
Value
Input
[
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
(
Arbitrary
Key
Input
[
SK
](),
StreamMaxLenInput
),
LongOutput
,
codec
,
executor
)
command
.
run
((
key
,
StreamMaxLen
(
approximate
,
count
)))
}
}
...
...
redis/src/main/scala/zio/redis/api/Strings.scala
浏览文件 @
fc43d270
...
...
@@ -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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
K
](),
NonEmptyList
(
BitFieldCommandInput
)),
ChunkOutput
(
OptionalOutput
(
LongOutput
)),
codec
,
executor
...
...
@@ -109,7 +110,7 @@ trait Strings extends RedisEnvironment {
val
command
=
RedisCommand
(
BitOp
,
Tuple3
(
BitOperationInput
,
Arbitrary
Input
[
D
](),
NonEmptyList
(
Arbitrary
Input
[
S
]())),
Tuple3
(
BitOperationInput
,
Arbitrary
ValueInput
[
D
](),
NonEmptyList
(
ArbitraryValue
Input
[
S
]())),
LongOutput
,
codec
,
executor
...
...
@@ -137,7 +138,7 @@ trait Strings extends RedisEnvironment {
val
command
=
RedisCommand
(
BitPos
,
Tuple3
(
ArbitraryInput
[
K
](),
BoolInput
,
OptionalInput
(
BitPosRangeInput
)),
Tuple3
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
Arbitrary
Input
[
V
]()),
Tuple2
(
Arbitrary
KeyInput
[
K
](),
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
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
,
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Key
Input
[
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
(
Arbitrary
Input
[
K
](),
DurationMillisecondsInput
,
Arbitrary
Input
[
V
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
DurationMillisecondsInput
,
ArbitraryValue
Input
[
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
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Value
Input
[
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
(
Arbitrary
Input
[
K
](),
DurationSecondsInput
,
Arbitrary
Input
[
V
]()),
Tuple3
(
Arbitrary
KeyInput
[
K
](),
DurationSecondsInput
,
ArbitraryValue
Input
[
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
,
Arbitrary
Key
Input
[
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
](),
Arbitrary
Value
Input
[
String
](),
Arbitrary
Key
Input
[
K
](),
Arbitrary
Key
Input
[
K
](),
OptionalInput
(
StralgoLcsQueryTypeInput
)
),
StrAlgoLcsOutput
,
...
...
redis/src/test/scala/zio/redis/InputSpec.scala
浏览文件 @
fc43d270
此差异已折叠。
点击以展开。
redis/src/test/scala/zio/redis/KeysSpec.scala
浏览文件 @
fc43d270
...
...
@@ -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
]
...
...
redis/src/test/scala/zio/redis/ScriptingSpec.scala
浏览文件 @
fc43d270
package
zio.redis
import
zio._
import
zio.redis.Input.
{
BoolInput
,
ByteInput
,
LongInput
,
String
Input
}
import
zio.redis.Input.
{
BoolInput
,
LongInput
,
StringInput
,
Value
Input
}
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
]]
=
Byt
eInput
implicit
val
bytesEncoder
:
Input
[
Chunk
[
Byte
]]
=
Valu
eInput
implicit
val
booleanInput
:
Input
[
Boolean
]
=
BoolInput
implicit
val
stringInput
:
Input
[
String
]
=
StringInput
implicit
val
longInput
:
Input
[
Long
]
=
LongInput
...
...
redis/src/test/scala/zio/redis/StreamsSpec.scala
浏览文件 @
fc43d270
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录