Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Zio Redis
提交
b19d2381
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 搜索 >>
未验证
提交
b19d2381
编写于
2月 11, 2023
作者:
D
Dejan Mijić
提交者:
GitHub
2月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweak visibility (#757)
上级
4242806b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
78 addition
and
92 deletion
+78
-92
redis/src/main/scala/zio/redis/ClusterExecutor.scala
redis/src/main/scala/zio/redis/ClusterExecutor.scala
+1
-1
redis/src/main/scala/zio/redis/Redis.scala
redis/src/main/scala/zio/redis/Redis.scala
+1
-4
redis/src/main/scala/zio/redis/RedisEnvironment.scala
redis/src/main/scala/zio/redis/RedisEnvironment.scala
+2
-2
redis/src/main/scala/zio/redis/api/Cluster.scala
redis/src/main/scala/zio/redis/api/Cluster.scala
+6
-6
redis/src/main/scala/zio/redis/api/Scripting.scala
redis/src/main/scala/zio/redis/api/Scripting.scala
+7
-7
redis/src/main/scala/zio/redis/api/Sets.scala
redis/src/main/scala/zio/redis/api/Sets.scala
+15
-15
redis/src/main/scala/zio/redis/api/SortedSets.scala
redis/src/main/scala/zio/redis/api/SortedSets.scala
+2
-2
redis/src/test/scala/zio/redis/ApiSpec.scala
redis/src/test/scala/zio/redis/ApiSpec.scala
+41
-49
redis/src/test/scala/zio/redis/BaseSpec.scala
redis/src/test/scala/zio/redis/BaseSpec.scala
+3
-6
未找到文件。
redis/src/main/scala/zio/redis/ClusterExecutor.scala
浏览文件 @
b19d2381
...
...
@@ -122,7 +122,7 @@ object ClusterExecutor {
ZIO
.
collectFirst
(
addresses
)
{
address
=>
connectToCluster
(
address
).
foldZIO
(
error
=>
ZIO
.
logError
(
s
"The connection to cluster
has been failed,
$error"
).
as
(
None
),
error
=>
ZIO
.
logError
(
s
"The connection to cluster
failed. Cause:
$error"
).
as
(
None
),
cc
=>
ZIO
.
logInfo
(
"The connection to cluster has been established"
).
as
(
Some
(
cc
))
)
}
...
...
redis/src/main/scala/zio/redis/Redis.scala
浏览文件 @
b19d2381
...
...
@@ -31,10 +31,7 @@ trait Redis
with
api
.
SortedSets
with
api
.
Streams
with
api
.
Scripting
with
api
.
Cluster
{
def
codec
:
BinaryCodec
def
executor
:
RedisExecutor
}
with
api
.
Cluster
object
Redis
{
lazy
val
layer
:
URLayer
[
RedisExecutor
with
BinaryCodec
,
Redis
]
=
...
...
redis/src/main/scala/zio/redis/RedisEnvironment.scala
浏览文件 @
b19d2381
...
...
@@ -19,6 +19,6 @@ package zio.redis
import
zio.schema.codec.BinaryCodec
private
[
redis
]
trait
RedisEnvironment
{
def
codec
:
BinaryCodec
def
executor
:
RedisExecutor
protected
def
codec
:
BinaryCodec
protected
def
executor
:
RedisExecutor
}
redis/src/main/scala/zio/redis/api/Cluster.scala
浏览文件 @
b19d2381
...
...
@@ -34,7 +34,7 @@ trait Cluster extends RedisEnvironment {
* @return
* the Unit value.
*/
def
asking
:
IO
[
RedisError
,
Unit
]
=
final
def
asking
:
IO
[
RedisError
,
Unit
]
=
AskingCommand
(
codec
,
executor
).
run
(())
/**
...
...
@@ -43,7 +43,7 @@ trait Cluster extends RedisEnvironment {
* @return
* details about which cluster
*/
def
slots
:
IO
[
RedisError
,
Chunk
[
Partition
]]
=
{
final
def
slots
:
IO
[
RedisError
,
Chunk
[
Partition
]]
=
{
val
command
=
RedisCommand
(
ClusterSlots
,
NoInput
,
ChunkOutput
(
ClusterPartitionOutput
),
codec
,
executor
)
command
.
run
(())
}
...
...
@@ -56,7 +56,7 @@ trait Cluster extends RedisEnvironment {
* @return
* the Unit value.
*/
def
setSlotStable
(
slot
:
Slot
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
setSlotStable
(
slot
:
Slot
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ClusterSetSlots
,
Tuple2
(
LongInput
,
ArbitraryInput
[
String
]()),
UnitOutput
,
codec
,
executor
)
command
.
run
((
slot
.
number
,
Stable
.
stringify
))
...
...
@@ -73,7 +73,7 @@ trait Cluster extends RedisEnvironment {
* @return
* the Unit value.
*/
def
setSlotMigrating
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
setSlotMigrating
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ClusterSetSlots
,
Tuple3
(
LongInput
,
ArbitraryInput
[
String
](),
ArbitraryInput
[
String
]()),
...
...
@@ -95,7 +95,7 @@ trait Cluster extends RedisEnvironment {
* @return
* the Unit value.
*/
def
setSlotImporting
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
setSlotImporting
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ClusterSetSlots
,
Tuple3
(
LongInput
,
ArbitraryInput
[
String
](),
ArbitraryInput
[
String
]()),
...
...
@@ -117,7 +117,7 @@ trait Cluster extends RedisEnvironment {
* @return
* the Unit value.
*/
def
setSlotNode
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
setSlotNode
(
slot
:
Slot
,
nodeId
:
String
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ClusterSetSlots
,
Tuple3
(
LongInput
,
ArbitraryInput
[
String
](),
ArbitraryInput
[
String
]()),
...
...
redis/src/main/scala/zio/redis/api/Scripting.scala
浏览文件 @
b19d2381
...
...
@@ -38,7 +38,7 @@ trait Scripting extends RedisEnvironment {
* redis protocol value that is converted from the Lua type. You have to write decoder that would convert redis
* protocol value to a suitable type for your app
*/
def
eval
[
K:
Input
,
A:
Input
](
final
def
eval
[
K:
Input
,
A:
Input
](
script
:
String
,
keys
:
Chunk
[
K
],
args
:
Chunk
[
A
]
...
...
@@ -63,7 +63,7 @@ trait Scripting extends RedisEnvironment {
* redis protocol value that is converted from the Lua type. You have to write decoder that would convert redis
* protocol value to a suitable type for your app
*/
def
evalSha
[
K:
Input
,
A:
Input
](
final
def
evalSha
[
K:
Input
,
A:
Input
](
sha1
:
String
,
keys
:
Chunk
[
K
],
args
:
Chunk
[
A
]
...
...
@@ -82,7 +82,7 @@ trait Scripting extends RedisEnvironment {
* @return
* the Unit value.
*/
def
scriptDebug
(
mode
:
DebugMode
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
scriptDebug
(
mode
:
DebugMode
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ScriptDebug
,
ScriptDebugInput
,
UnitOutput
,
codec
,
executor
)
command
.
run
(
mode
)
}
...
...
@@ -98,7 +98,7 @@ trait Scripting extends RedisEnvironment {
* for every corresponding SHA1 digest of a script that actually exists in the script cache, an true is returned,
* otherwise false is returned.
*/
def
scriptExists
(
sha1
:
String
,
sha1s
:
String*
)
:
IO
[
RedisError
,
Chunk
[
Boolean
]]
=
{
final
def
scriptExists
(
sha1
:
String
,
sha1s
:
String*
)
:
IO
[
RedisError
,
Chunk
[
Boolean
]]
=
{
val
command
=
RedisCommand
(
ScriptExists
,
NonEmptyList
(
StringInput
),
ChunkOutput
(
BoolOutput
),
codec
,
executor
)
command
.
run
((
sha1
,
sha1s
.
toList
))
}
...
...
@@ -112,7 +112,7 @@ trait Scripting extends RedisEnvironment {
* @return
* the Unit value.
*/
def
scriptFlush
(
mode
:
Option
[
FlushMode
]
=
None
)
:
IO
[
RedisError
,
Unit
]
=
{
final
def
scriptFlush
(
mode
:
Option
[
FlushMode
]
=
None
)
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ScriptFlush
,
OptionalInput
(
ScriptFlushInput
),
UnitOutput
,
codec
,
executor
)
command
.
run
(
mode
)
}
...
...
@@ -123,7 +123,7 @@ trait Scripting extends RedisEnvironment {
* @return
* the Unit value.
*/
def
scriptKill
:
IO
[
RedisError
,
Unit
]
=
{
final
def
scriptKill
:
IO
[
RedisError
,
Unit
]
=
{
val
command
=
RedisCommand
(
ScriptKill
,
NoInput
,
UnitOutput
,
codec
,
executor
)
command
.
run
(())
}
...
...
@@ -137,7 +137,7 @@ trait Scripting extends RedisEnvironment {
* @return
* the SHA1 digest of the script added into the script cache.
*/
def
scriptLoad
(
script
:
String
)
:
IO
[
RedisError
,
String
]
=
{
final
def
scriptLoad
(
script
:
String
)
:
IO
[
RedisError
,
String
]
=
{
val
command
=
RedisCommand
(
ScriptLoad
,
StringInput
,
MultiStringOutput
,
codec
,
executor
)
command
.
run
(
script
)
}
...
...
redis/src/main/scala/zio/redis/api/Sets.scala
浏览文件 @
b19d2381
...
...
@@ -347,19 +347,19 @@ trait Sets extends RedisEnvironment {
}
private
[
redis
]
object
Sets
{
val
SAdd
=
"SADD"
val
SCard
=
"SCARD"
val
SDiff
=
"SDIFF"
val
SDiffStore
=
"SDIFFSTORE"
val
SInter
=
"SINTER"
val
SInterStore
=
"SINTERSTORE"
val
SIsMember
=
"SISMEMBER"
val
SMembers
=
"SMEMBERS"
val
SMove
=
"SMOVE"
val
SPop
=
"SPOP"
val
SRandMember
=
"SRANDMEMBER"
val
SRem
=
"SREM"
val
SScan
=
"SSCAN"
val
SUnion
=
"SUNION"
val
SUnionStore
=
"SUNIONSTORE"
final
val
SAdd
=
"SADD"
final
val
SCard
=
"SCARD"
final
val
SDiff
=
"SDIFF"
final
val
SDiffStore
=
"SDIFFSTORE"
final
val
SInter
=
"SINTER"
final
val
SInterStore
=
"SINTERSTORE"
final
val
SIsMember
=
"SISMEMBER"
final
val
SMembers
=
"SMEMBERS"
final
val
SMove
=
"SMOVE"
final
val
SPop
=
"SPOP"
final
val
SRandMember
=
"SRANDMEMBER"
final
val
SRem
=
"SREM"
final
val
SScan
=
"SSCAN"
final
val
SUnion
=
"SUNION"
final
val
SUnionStore
=
"SUNIONSTORE"
}
redis/src/main/scala/zio/redis/api/SortedSets.scala
浏览文件 @
b19d2381
...
...
@@ -1149,7 +1149,7 @@ trait SortedSets extends RedisEnvironment {
*/
final
def
zMScore
[
K:
Schema
](
key
:
K
,
keys
:
K*
)
:
IO
[
RedisError
,
Chunk
[
Option
[
Double
]]]
=
{
val
command
=
RedisCommand
(
Z
ms
core
,
Z
MS
core
,
NonEmptyList
(
ArbitraryInput
[
K
]()),
ChunkOutput
(
OptionalOutput
(
DoubleOutput
)),
codec
,
...
...
@@ -1245,6 +1245,7 @@ private[redis] object SortedSets {
final
val
ZInter
=
"ZINTER"
final
val
ZInterStore
=
"ZINTERSTORE"
final
val
ZLexCount
=
"ZLEXCOUNT"
final
val
ZMScore
=
"ZMSCORE"
final
val
ZPopMax
=
"ZPOPMAX"
final
val
ZPopMin
=
"ZPOPMIN"
final
val
ZRange
=
"ZRANGE"
...
...
@@ -1263,6 +1264,5 @@ private[redis] object SortedSets {
final
val
ZScore
=
"ZSCORE"
final
val
ZUnion
=
"ZUNION"
final
val
ZUnionStore
=
"ZUNIONSTORE"
final
val
Zmscore
=
"ZMSCORE"
final
val
ZRandMember
=
"ZRANDMEMBER"
}
redis/src/test/scala/zio/redis/ApiSpec.scala
浏览文件 @
b19d2381
package
zio.redis
import
zio._
import
zio.test.TestAspect._
import
zio.test._
import
zio.
{
Chunk
,
Layer
,
ZLayer
}
object
ApiSpec
extends
ConnectionSpec
...
...
@@ -19,54 +19,46 @@ object ApiSpec
with
ClusterSpec
{
def
spec
:
Spec
[
TestEnvironment
,
Any
]
=
suite
(
"Redis commands"
)(
Node
.
Suite
.
provideLayerShared
(
Node
.
Layer
)
@@
sequential
@@
withLiveEnvironment
,
Cluster
.
Suite
.
provideLayerShared
(
Cluster
.
Layer
)
@@
sequential
@@
withLiveEnvironment
)
private
object
Node
{
val
Suite
:
Spec
[
Redis
,
Any
]
=
suite
(
"Node Executor"
)(
connectionSuite
,
keysSuite
,
listSuite
,
setsSuite
,
sortedSetsSuite
,
stringsSuite
,
geoSuite
,
hyperLogLogSuite
,
hashSuite
,
streamsSuite
,
scriptingSpec
)
val
Layer
:
Layer
[
Any
,
Redis
]
=
ZLayer
.
make
[
Redis
](
RedisExecutor
.
local
.
orDie
,
ZLayer
.
succeed
(
codec
),
Redis
.
layer
)
}
suite
(
"Redis commands"
)(
clusterSuite
,
singleNodeSuite
)
@@
sequential
@@
withLiveEnvironment
private
object
Cluster
{
val
Suite
:
Spec
[
Redis
,
Any
]
=
suite
(
"Cluster Executor"
)(
connectionSuite
,
keysSuite
,
listSuite
,
stringsSuite
,
hashSuite
,
setsSuite
,
sortedSetsSuite
,
hyperLogLogSuite
,
geoSuite
,
streamsSuite
@@
clusterExecutorUnsupported
,
scriptingSpec
@@
clusterExecutorUnsupported
,
clusterSpec
).
filterAnnotations
(
TestAnnotation
.
tagged
)(
t
=>
!
t
.
contains
(
BaseSpec
.
ClusterExecutorUnsupported
)).
get
val
Layer
:
Layer
[
Any
,
Redis
]
=
ZLayer
.
make
[
Redis
](
ZLayer
.
succeed
(
RedisClusterConfig
(
Chunk
(
RedisUri
(
"localhost"
,
5000
)))),
ClusterExecutor
.
layer
,
ZLayer
.
succeed
(
codec
),
Redis
.
layer
)
}
private
val
singleNodeSuite
=
suite
(
"Single node executor"
)(
connectionSuite
,
keysSuite
,
listSuite
,
setsSuite
,
sortedSetsSuite
,
stringsSuite
,
geoSuite
,
hyperLogLogSuite
,
hashSuite
,
streamsSuite
,
scriptingSpec
).
provideShared
(
RedisExecutor
.
local
,
Redis
.
layer
,
ZLayer
.
succeed
(
codec
)
)
private
val
clusterSuite
=
suite
(
"Cluster executor"
)(
connectionSuite
,
keysSuite
,
listSuite
,
stringsSuite
,
hashSuite
,
setsSuite
,
sortedSetsSuite
,
hyperLogLogSuite
,
geoSuite
,
streamsSuite
@@
clusterExecutorUnsupported
,
scriptingSpec
@@
clusterExecutorUnsupported
,
clusterSpec
).
provideShared
(
ClusterExecutor
.
layer
,
Redis
.
layer
,
ZLayer
.
succeed
(
codec
),
ZLayer
.
succeed
(
RedisClusterConfig
(
Chunk
(
RedisUri
(
"localhost"
,
5000
))))
).
filterNotTags
(
_
.
contains
(
BaseSpec
.
ClusterExecutorUnsupported
))
.
getOrElse
(
Spec
.
empty
)
}
redis/src/test/scala/zio/redis/BaseSpec.scala
浏览文件 @
b19d2381
...
...
@@ -2,19 +2,16 @@ package zio.redis
import
zio._
import
zio.schema.codec.
{
BinaryCodec
,
ProtobufCodec
}
import
zio.test.TestAspect.
tag
import
zio.test.TestAspect.
{
fibers
,
silentLogging
,
tag
,
timeout
}
import
zio.test._
import
java.time.Instant
import
java.util.UUID
trait
BaseSpec
extends
ZIOSpecDefault
{
implicit
val
codec
:
BinaryCodec
=
ProtobufCodec
override
def
aspects
:
Chunk
[
TestAspectAtLeastR
[
Live
]]
=
Chunk
.
succeed
(
TestAspect
.
timeout
(
10.
seconds
))
def
instantOf
(
millis
:
Long
)
:
UIO
[
Instant
]
=
ZIO
.
succeed
(
Instant
.
now
().
plusMillis
(
millis
))
Chunk
(
fibers
,
silentLogging
,
timeout
(
10.
seconds
))
final
val
genStringRedisTypeOption
:
Gen
[
Any
,
Option
[
RedisType
]]
=
Gen
.
option
(
Gen
.
constSample
(
Sample
.
noShrink
(
RedisType
.
String
)))
...
...
@@ -39,5 +36,5 @@ trait BaseSpec extends ZIOSpecDefault {
}
object
BaseSpec
{
final
val
ClusterExecutorUnsupported
=
"cluster executor
un
supported"
final
val
ClusterExecutorUnsupported
=
"cluster executor
not
supported"
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录