Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Zio Redis
比较版本
0111c5342bb632ebe1560d13ad6ecfe10d5ef053...7dabd5b5b749d9558f95406fc1cc44e297dec181
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 搜索 >>
源分支
7dabd5b5b749d9558f95406fc1cc44e297dec181
选择Git版本
...
目标分支
0111c5342bb632ebe1560d13ad6ecfe10d5ef053
选择Git版本
比较
Commits (6)
https://gitcode.net/qq_34446485/zio-redis/-/commit/9268e9d446835e5bb89daea857989b387aea3f2d
Support 'CLIENT INFO' and 'CLIENT LIST' commands (#807)
2023-04-09T13:19:00+02:00
Dragutin Marjanović
dmarjanovic94@gmail.com
https://gitcode.net/qq_34446485/zio-redis/-/commit/7b507fcb14f775b729575a34798d9bf22a0c3a55
Hide executors (#809)
2023-04-09T13:31:54+02:00
Dejan Mijić
dmijic@acm.org
https://gitcode.net/qq_34446485/zio-redis/-/commit/70d2b1015303deea284316a64dd7cf4e62567c91
Update README.md (#810)
2023-04-09T13:39:57+02:00
github-actions[bot]
41898282+github-actions[bot]@users.noreply.github.com
Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:github-actions%5Bbot%5D@users.noreply.github.com" title="github-actions[bot]@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg6" style="text-decoration: none">N</a><a href="mailto:github-actions%5Bbot%5D@users.noreply.github.com" title="github-actions[bot]@users.noreply.github.com">github-actions[bot]</a> <<a href="mailto:github-actions%5Bbot%5D@users.noreply.github.com" title="github-actions[bot]@users.noreply.github.com">github-actions[bot]@users.noreply.github.com</a>></span>
https://gitcode.net/qq_34446485/zio-redis/-/commit/edbf01294614d9c9c570441eedfa2e0dadc917cc
Remove redundant benchmarks (#811)
2023-04-09T21:25:15+02:00
Dejan Mijić
dmijic@acm.org
https://gitcode.net/qq_34446485/zio-redis/-/commit/b457e8ea6f80b147d471491222aa2beafd17fe2c
Inline benchmark package object (#814)
2023-04-10T09:25:14+02:00
Dejan Mijić
dmijic@acm.org
https://gitcode.net/qq_34446485/zio-redis/-/commit/7dabd5b5b749d9558f95406fc1cc44e297dec181
Change return type of CLIENT INFO and CLIENT LIST (#813)
2023-04-10T20:42:49+02:00
Dragutin Marjanović
dmarjanovic94@gmail.com
* Remove unused class * Parse responses to ClientInfo * Improve docs * Address code remarks * Add 'from(char)' method to ClientFlag object * Add 'final' modifier * Make parsing ClientInfo safe * Use scala-collection-compat * Format code
展开全部
隐藏空白更改
内联
并排
Showing
85 changed file
with
521 addition
and
4241 deletion
+521
-4241
README.md
README.md
+14
-17
build.sbt
build.sbt
+3
-5
docs/index.md
docs/index.md
+14
-17
modules/benchmarks/src/main/scala/zio/redis/benchmarks/QueryRunner.scala
...rks/src/main/scala/zio/redis/benchmarks/QueryRunner.scala
+0
-84
modules/benchmarks/src/main/scala/zio/redis/benchmarks/Redis4Cats.scala
...arks/src/main/scala/zio/redis/benchmarks/Redis4Cats.scala
+56
-0
modules/benchmarks/src/main/scala/zio/redis/benchmarks/SetGetBenchmark.scala
...src/main/scala/zio/redis/benchmarks/SetGetBenchmark.scala
+80
-0
modules/benchmarks/src/main/scala/zio/redis/benchmarks/ZioRedis.scala
...hmarks/src/main/scala/zio/redis/benchmarks/ZioRedis.scala
+18
-18
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HDelBenchmarks.scala
...main/scala/zio/redis/benchmarks/hash/HDelBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HExistsBenchmarks.scala
...n/scala/zio/redis/benchmarks/hash/HExistsBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HGetAllBenchmarks.scala
...n/scala/zio/redis/benchmarks/hash/HGetAllBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HGetBenchmarks.scala
...main/scala/zio/redis/benchmarks/hash/HGetBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HIncrbyBenchmarks.scala
...n/scala/zio/redis/benchmarks/hash/HIncrbyBenchmarks.scala
+0
-79
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HIncrbyFloatBenchmarks.scala
...la/zio/redis/benchmarks/hash/HIncrbyFloatBenchmarks.scala
+0
-81
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HKeysBenchmarks.scala
...ain/scala/zio/redis/benchmarks/hash/HKeysBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HLenBenchmarks.scala
...main/scala/zio/redis/benchmarks/hash/HLenBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HMGetBenchmarks.scala
...ain/scala/zio/redis/benchmarks/hash/HMGetBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HMSetBenchmarks.scala
...ain/scala/zio/redis/benchmarks/hash/HMSetBenchmarks.scala
+0
-70
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HSetBenchmarks.scala
...main/scala/zio/redis/benchmarks/hash/HSetBenchmarks.scala
+0
-70
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HSetNxBenchmarks.scala
...in/scala/zio/redis/benchmarks/hash/HSetNxBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HStrLenBenchmarks.scala
...n/scala/zio/redis/benchmarks/hash/HStrLenBenchmarks.scala
+0
-70
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HValsBenchmarks.scala
...ain/scala/zio/redis/benchmarks/hash/HValsBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BlMoveBenchmarks.scala
...n/scala/zio/redis/benchmarks/lists/BlMoveBenchmarks.scala
+0
-57
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BlPopBenchmarks.scala
...in/scala/zio/redis/benchmarks/lists/BlPopBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BrPopBenchmarks.scala
...in/scala/zio/redis/benchmarks/lists/BrPopBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BrPopLPushBenchmarks.scala
...ala/zio/redis/benchmarks/lists/BrPopLPushBenchmarks.scala
+0
-87
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LIndexBenchmarks.scala
...n/scala/zio/redis/benchmarks/lists/LIndexBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LInsertBenchmarks.scala
.../scala/zio/redis/benchmarks/lists/LInsertBenchmarks.scala
+0
-83
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LLenBenchmarks.scala
...ain/scala/zio/redis/benchmarks/lists/LLenBenchmarks.scala
+0
-72
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPopBenchmarks.scala
...ain/scala/zio/redis/benchmarks/lists/LPopBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPosCountBenchmarks.scala
...cala/zio/redis/benchmarks/lists/LPosCountBenchmarks.scala
+0
-54
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPushBenchmarks.scala
...in/scala/zio/redis/benchmarks/lists/LPushBenchmarks.scala
+0
-76
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPushXBenchmarks.scala
...n/scala/zio/redis/benchmarks/lists/LPushXBenchmarks.scala
+0
-78
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LRangeBenchmarks.scala
...n/scala/zio/redis/benchmarks/lists/LRangeBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LRemBenchmarks.scala
...ain/scala/zio/redis/benchmarks/lists/LRemBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LSetBenchmarks.scala
...ain/scala/zio/redis/benchmarks/lists/LSetBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LTrimBenchmarks.scala
...in/scala/zio/redis/benchmarks/lists/LTrimBenchmarks.scala
+0
-76
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPopBenchmarks.scala
...ain/scala/zio/redis/benchmarks/lists/RPopBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPopLPushBenchmarks.scala
...cala/zio/redis/benchmarks/lists/RPopLPushBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPushBenchmarks.scala
...in/scala/zio/redis/benchmarks/lists/RPushBenchmarks.scala
+0
-76
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPushXBenchmarks.scala
...n/scala/zio/redis/benchmarks/lists/RPushXBenchmarks.scala
+0
-78
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SAddBenchmarks.scala
...main/scala/zio/redis/benchmarks/sets/SAddBenchmarks.scala
+0
-71
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SCardBenchmarks.scala
...ain/scala/zio/redis/benchmarks/sets/SCardBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SDiffBenchmarks.scala
...ain/scala/zio/redis/benchmarks/sets/SDiffBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SDiffStoreBenchmarks.scala
...cala/zio/redis/benchmarks/sets/SDiffStoreBenchmarks.scala
+0
-87
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SInterBenchmarks.scala
...in/scala/zio/redis/benchmarks/sets/SInterBenchmarks.scala
+0
-82
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SInterStoreBenchmarks.scala
...ala/zio/redis/benchmarks/sets/SInterStoreBenchmarks.scala
+0
-87
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SIsMemberBenchmarks.scala
...scala/zio/redis/benchmarks/sets/SIsMemberBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SMembersBenchmarks.scala
.../scala/zio/redis/benchmarks/sets/SMembersBenchmarks.scala
+0
-74
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SMoveBenchmarks.scala
...ain/scala/zio/redis/benchmarks/sets/SMoveBenchmarks.scala
+0
-76
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SPopBenchmarks.scala
...main/scala/zio/redis/benchmarks/sets/SPopBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SRandMemberBenchmarks.scala
...ala/zio/redis/benchmarks/sets/SRandMemberBenchmarks.scala
+0
-75
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SRemBenchmarks.scala
...main/scala/zio/redis/benchmarks/sets/SRemBenchmarks.scala
+0
-73
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SUnionBenchmarks.scala
...in/scala/zio/redis/benchmarks/sets/SUnionBenchmarks.scala
+0
-81
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SUnionStoreBenchmarks.scala
...ala/zio/redis/benchmarks/sets/SUnionStoreBenchmarks.scala
+0
-87
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/AppendBenchmarks.scala
...scala/zio/redis/benchmarks/strings/AppendBenchmarks.scala
+0
-65
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/DecrBenchmarks.scala
...n/scala/zio/redis/benchmarks/strings/DecrBenchmarks.scala
+0
-65
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/GetBenchmarks.scala
...in/scala/zio/redis/benchmarks/strings/GetBenchmarks.scala
+0
-67
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/GetBitBenchmarks.scala
...scala/zio/redis/benchmarks/strings/GetBitBenchmarks.scala
+0
-65
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/SetBenchmarks.scala
...in/scala/zio/redis/benchmarks/strings/SetBenchmarks.scala
+0
-69
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/StrLenBenchmarks.scala
...scala/zio/redis/benchmarks/strings/StrLenBenchmarks.scala
+0
-70
modules/embedded/src/test/scala/zio/redis/embedded/EmbeddedRedisSpec.scala
...src/test/scala/zio/redis/embedded/EmbeddedRedisSpec.scala
+1
-2
modules/example/src/main/scala/example/Main.scala
modules/example/src/main/scala/example/Main.scala
+1
-2
modules/redis/src/main/scala/zio/redis/Input.scala
modules/redis/src/main/scala/zio/redis/Input.scala
+14
-0
modules/redis/src/main/scala/zio/redis/Output.scala
modules/redis/src/main/scala/zio/redis/Output.scala
+17
-1
modules/redis/src/main/scala/zio/redis/Redis.scala
modules/redis/src/main/scala/zio/redis/Redis.scala
+11
-1
modules/redis/src/main/scala/zio/redis/api/Cluster.scala
modules/redis/src/main/scala/zio/redis/api/Cluster.scala
+1
-1
modules/redis/src/main/scala/zio/redis/api/Connection.scala
modules/redis/src/main/scala/zio/redis/api/Connection.scala
+41
-0
modules/redis/src/main/scala/zio/redis/internal/ClusterConnection.scala
...src/main/scala/zio/redis/internal/ClusterConnection.scala
+32
-0
modules/redis/src/main/scala/zio/redis/internal/ClusterExecutor.scala
...s/src/main/scala/zio/redis/internal/ClusterExecutor.scala
+12
-11
modules/redis/src/main/scala/zio/redis/internal/ExecutorScope.scala
...dis/src/main/scala/zio/redis/internal/ExecutorScope.scala
+21
-0
modules/redis/src/main/scala/zio/redis/internal/RedisEnvironment.scala
.../src/main/scala/zio/redis/internal/RedisEnvironment.scala
+1
-1
modules/redis/src/main/scala/zio/redis/internal/RedisExecutor.scala
...dis/src/main/scala/zio/redis/internal/RedisExecutor.scala
+4
-4
modules/redis/src/main/scala/zio/redis/internal/SingleNodeExecutor.scala
...rc/main/scala/zio/redis/internal/SingleNodeExecutor.scala
+12
-12
modules/redis/src/main/scala/zio/redis/internal/package.scala
...les/redis/src/main/scala/zio/redis/internal/package.scala
+11
-8
modules/redis/src/main/scala/zio/redis/options/Cluster.scala
modules/redis/src/main/scala/zio/redis/options/Cluster.scala
+3
-17
modules/redis/src/main/scala/zio/redis/options/Connection.scala
...s/redis/src/main/scala/zio/redis/options/Connection.scala
+87
-37
modules/redis/src/main/scala/zio/redis/options/Streams.scala
modules/redis/src/main/scala/zio/redis/options/Streams.scala
+0
-2
modules/redis/src/main/scala/zio/redis/package.scala
modules/redis/src/main/scala/zio/redis/package.scala
+0
-9
modules/redis/src/test/scala/zio/redis/ApiSpec.scala
modules/redis/src/test/scala/zio/redis/ApiSpec.scala
+2
-7
modules/redis/src/test/scala/zio/redis/ConnectionSpec.scala
modules/redis/src/test/scala/zio/redis/ConnectionSpec.scala
+35
-1
modules/redis/src/test/scala/zio/redis/InputSpec.scala
modules/redis/src/test/scala/zio/redis/InputSpec.scala
+15
-1
modules/redis/src/test/scala/zio/redis/KeysSpec.scala
modules/redis/src/test/scala/zio/redis/KeysSpec.scala
+1
-2
modules/redis/src/test/scala/zio/redis/SortedSetsSpec.scala
modules/redis/src/test/scala/zio/redis/SortedSetsSpec.scala
+2
-2
modules/redis/src/test/scala/zio/redis/internal/ClusterExecutorSpec.scala
...c/test/scala/zio/redis/internal/ClusterExecutorSpec.scala
+7
-12
project/BuildHelper.scala
project/BuildHelper.scala
+5
-2
未找到文件。
README.md
浏览文件 @
7dabd5b5
...
...
@@ -49,21 +49,19 @@ object ZIORedisExample extends ZIOAppDefault {
def
get
[
A:
Schema
]
:
BinaryCodec
[
A
]
=
ProtobufCodec
.
protobufCodec
}
val
myApp
:
ZIO
[
Redis
,
RedisError
,
Unit
]
=
for
{
redis
<-
ZIO
.
service
[
Redis
]
_
<-
redis
.
set
(
"myKey"
,
8L
,
Some
(
1.
minutes
))
v
<-
redis
.
get
(
"myKey"
).
returning
[
Long
]
_
<-
Console
.
printLine
(
s
"Value of myKey: $v"
).
orDie
_
<-
redis
.
hSet
(
"myHash"
,
(
"k1"
,
6
),
(
"k2"
,
2
))
_
<-
redis
.
rPush
(
"myList"
,
1
,
2
,
3
,
4
)
_
<-
redis
.
sAdd
(
"mySet"
,
"a"
,
"b"
,
"a"
,
"c"
)
}
yield
()
override
def
run
=
myApp
.
provide
(
Redis
.
layer
,
SingleNodeExecutor
.
local
,
ZLayer
.
succeed
[
CodecSupplier
](
ProtobufCodecSupplier
)
)
val
myApp
:
ZIO
[
Redis
,
RedisError
,
Unit
]
=
for
{
redis
<-
ZIO
.
service
[
Redis
]
_
<-
redis
.
set
(
"myKey"
,
8L
,
Some
(
1.
minutes
))
v
<-
redis
.
get
(
"myKey"
).
returning
[
Long
]
_
<-
Console
.
printLine
(
s
"Value of myKey: $v"
).
orDie
_
<-
redis
.
hSet
(
"myHash"
,
(
"k1"
,
6
),
(
"k2"
,
2
))
_
<-
redis
.
rPush
(
"myList"
,
1
,
2
,
3
,
4
)
_
<-
redis
.
sAdd
(
"mySet"
,
"a"
,
"b"
,
"a"
,
"c"
)
}
yield
()
override
def
run
=
myApp
.
provide
(
Redis
.
local
,
ZLayer
.
succeed
[
CodecSupplier
](
ProtobufCodecSupplier
))
}
```
...
...
@@ -108,9 +106,8 @@ object EmbeddedRedisSpec extends ZIOSpecDefault {
}
).
provideShared
(
EmbeddedRedis
.
layer
,
SingleNodeExecutor
.
layer
,
ZLayer
.
succeed
[
CodecSupplier
](
ProtobufCodecSupplier
),
Redis
.
layer
Redis
.
singleNode
)
@@
TestAspect
.
silentLogging
}
```
...
...
build.sbt
浏览文件 @
7dabd5b5
...
...
@@ -45,7 +45,6 @@ lazy val redis =
.
settings
(
libraryDependencies
++=
List
(
"dev.zio"
%%
"zio-streams"
%
zioVersion
,
"dev.zio"
%%
"zio-logging"
%
"2.1.11"
,
"dev.zio"
%%
"zio-schema"
%
zioSchemaVersion
,
"dev.zio"
%%
"zio-schema-protobuf"
%
zioSchemaVersion
%
Test
,
"dev.zio"
%%
"zio-test"
%
zioVersion
%
Test
,
...
...
@@ -85,10 +84,9 @@ lazy val benchmarks =
crossScalaVersions
-=
Scala3
,
publish
/
skip
:=
true
,
libraryDependencies
++=
List
(
"dev.profunktor"
%%
"redis4cats-effects"
%
"1.4.1"
,
"io.chrisdavenport"
%%
"rediculous"
%
"0.4.0"
,
"io.laserdisc"
%%
"laserdisc-fs2"
%
"0.6.0"
,
"dev.zio"
%%
"zio-schema-protobuf"
%
zioSchemaVersion
"dev.profunktor"
%%
"redis4cats-effects"
%
"1.4.1"
,
"dev.zio"
%%
"zio-schema-protobuf"
%
zioSchemaVersion
,
"org.typelevel"
%%
"cats-effect"
%
"3.4.8"
)
)
...
...
docs/index.md
浏览文件 @
7dabd5b5
...
...
@@ -49,21 +49,19 @@ object ZIORedisExample extends ZIOAppDefault {
def get[A: Schema]: BinaryCodec[A] = ProtobufCodec.protobufCodec
}
val myApp: ZIO[Redis, RedisError, Unit] = for {
redis <- ZIO.service[Redis]
_ <- redis.set("myKey", 8L, Some(1.minutes))
v <- redis.get("myKey").returning[Long]
_ <- Console.printLine(s"Value of myKey: $v").orDie
_ <- redis.hSet("myHash", ("k1", 6), ("k2", 2))
_ <- redis.rPush("myList", 1, 2, 3, 4)
_ <- redis.sAdd("mySet", "a", "b", "a", "c")
} yield ()
override def run = myApp.provide(
Redis.layer,
SingleNodeExecutor.local,
ZLayer.succeed[CodecSupplier](ProtobufCodecSupplier)
)
val myApp: ZIO[Redis, RedisError, Unit] =
for {
redis <- ZIO.service[Redis]
_ <- redis.set("myKey", 8L, Some(1.minutes))
v <- redis.get("myKey").returning[Long]
_ <- Console.printLine(s"Value of myKey: $v").orDie
_ <- redis.hSet("myHash", ("k1", 6), ("k2", 2))
_ <- redis.rPush("myList", 1, 2, 3, 4)
_ <- redis.sAdd("mySet", "a", "b", "a", "c")
} yield ()
override def run =
myApp.provide(Redis.local, ZLayer.succeed[CodecSupplier](ProtobufCodecSupplier))
}
```
...
...
@@ -108,9 +106,8 @@ object EmbeddedRedisSpec extends ZIOSpecDefault {
}
).provideShared(
EmbeddedRedis.layer,
SingleNodeExecutor.layer,
ZLayer.succeed[CodecSupplier](ProtobufCodecSupplier),
Redis.
layer
Redis.
singleNode
) @@ TestAspect.silentLogging
}
```
...
...
modules/benchmarks/src/main/scala/zio/redis/benchmarks/QueryRunner.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks
import
cats.effect.unsafe.implicits.global
import
cats.effect.
{
IO
=>
CIO
,
Resource
}
import
com.comcast.ip4s._
import
dev.profunktor.redis4cats.codecs.Codecs
import
dev.profunktor.redis4cats.codecs.splits._
import
dev.profunktor.redis4cats.data.RedisCodec
import
dev.profunktor.redis4cats.effect.Log.NoOp.instance
import
dev.profunktor.redis4cats.
{
Redis
,
RedisCommands
}
import
io.chrisdavenport.rediculous.RedisConnection
import
io.lettuce.core.ClientOptions
import
laserdisc.auto.autoRefine
import
laserdisc.fs2.RedisClient
trait
QueryRunner
[
Client
]
{
def
unsafeRunWith
(
query
:
Client
=>
CIO
[
Unit
])
:
Unit
}
object
QueryRunner
{
def
apply
[
Client
](
implicit
instance
:
QueryRunner
[
Client
])
:
QueryRunner
[
Client
]
=
instance
implicit
val
laserDiscClientRunner
:
QueryRunner
[
LaserDiscClient
]
=
new
QueryRunner
[
LaserDiscClient
]
{
def
unsafeRunWith
(
f
:
LaserDiscClient
=>
CIO
[
Unit
])
:
Unit
=
Laserdisc
.
use
(
f
).
unsafeRunSync
()
}
implicit
val
rediculousRunner
:
QueryRunner
[
RediculousClient
]
=
new
QueryRunner
[
RediculousClient
]
{
def
unsafeRunWith
(
f
:
RediculousClient
=>
CIO
[
Unit
])
:
Unit
=
Rediculous
.
use
(
f
).
unsafeRunSync
()
}
implicit
val
redis4CatsStringRunner
:
QueryRunner
[
Redis4CatsClient
[
String
]]
=
new
QueryRunner
[
Redis4CatsClient
[
String
]]
{
def
unsafeRunWith
(
f
:
Redis4CatsClient
[
String
]
=>
CIO
[
Unit
])
:
Unit
=
Redis4CatsString
.
use
(
f
).
unsafeRunSync
()
}
implicit
val
redis4CatsLongRunner
:
QueryRunner
[
Redis4CatsClient
[
Long
]]
=
new
QueryRunner
[
Redis4CatsClient
[
Long
]]
{
def
unsafeRunWith
(
f
:
Redis4CatsClient
[
Long
]
=>
CIO
[
Unit
])
:
Unit
=
Redis4CatsLong
.
use
(
f
).
unsafeRunSync
()
}
private
[
this
]
final
val
RedisHost
=
"127.0.0.1"
private
[
this
]
final
val
RedisPort
=
6379
private
[
this
]
final
val
Laserdisc
:
Resource
[
CIO
,
LaserDiscClient
]
=
RedisClient
[
CIO
].
to
(
RedisHost
,
RedisPort
)
private
[
this
]
final
val
Rediculous
:
Resource
[
CIO
,
RediculousClient
]
=
RedisConnection
.
queued
[
CIO
]
.
withHost
(
host
"127.0.0.1"
)
.
withPort
(
port
"6379"
)
.
withMaxQueued
(
10000
)
.
withWorkers
(
2
)
.
build
private
[
this
]
final
val
Redis4CatsLong
:
Resource
[
CIO
,
RedisCommands
[
CIO
,
String
,
Long
]]
=
{
val
longCodec
=
Codecs
.
derive
(
RedisCodec
.
Utf8
,
stringLongEpi
)
Redis
[
CIO
].
withOptions
(
s
"redis://$RedisHost:$RedisPort"
,
ClientOptions
.
create
(),
longCodec
)
}
private
[
this
]
final
val
Redis4CatsString
:
Resource
[
CIO
,
RedisCommands
[
CIO
,
String
,
String
]]
=
Redis
[
CIO
].
utf8
(
s
"redis://$RedisHost:$RedisPort"
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
lists/LMoveBenchmark
s.scala
→
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
Redis4Cat
s.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,43 +14,43 @@
* limitations under the License.
*/
package
zio.redis.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LMoveBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
package
zio.redis.benchmarks
import
cats.effect._
import
cats.effect.unsafe.IORuntime
import
dev.profunktor.redis4cats.codecs.Codecs
import
dev.profunktor.redis4cats.codecs.splits._
import
dev.profunktor.redis4cats.data.RedisCodec
import
dev.profunktor.redis4cats.effect.Log.NoOp.instance
import
dev.profunktor.redis4cats.
{
Redis
,
RedisCommands
}
import
io.lettuce.core.ClientOptions
private
[
benchmarks
]
final
class
Redis4Cats
private
(
client
:
RedisCommands
[
IO
,
String
,
Long
],
finalizer
:
IO
[
Unit
]
)(
implicit
runtime
:
IORuntime
)
{
def
run
(
program
:
RedisCommands
[
IO
,
String
,
Long
]
=>
IO
[
Unit
])
:
Unit
=
program
(
client
).
unsafeRunSync
()
def
tearDown
()
:
Unit
=
finalizer
.
unsafeRunSync
()
}
private
var
items
:
List
[
String
]
=
_
private
[
benchmarks
]
object
Redis4Cats
{
implicit
val
runtime
:
IORuntime
=
IORuntime
.
global
private
val
key
=
"test-list"
def
unsafeMake
()
:
Redis4Cats
=
{
val
resource
=
Redis
[
IO
].
withOptions
(
RedisUri
,
ClientOptions
.
create
(),
LongCodec
)
val
(
client
,
finalizer
)
=
extractResource
(
resource
).
unsafeRunSync
()
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
new
Redis4Cats
(
client
,
finalizer
)
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
private
def
extractResource
[
A
](
resource
:
Resource
[
IO
,
A
])
:
IO
[(
A
,
IO
[
Unit
])]
=
for
{
da
<-
Deferred
[
IO
,
A
]
f
<-
resource
.
use
(
da
.
complete
(
_
)
>>
IO
.
never
).
start
a
<-
da
.
get
}
yield
a
->
f
.
cancel
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lMove
(
key
,
key
,
Side
.
Left
,
Side
.
Right
).
returning
[
String
])
)
)
private
final
val
LongCodec
=
Codecs
.
derive
(
RedisCodec
.
Utf8
,
stringLongEpi
)
private
final
val
RedisUri
=
"redis://127.0.0.1:6379"
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
strings/IncrBenchmarks
.scala
→
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
SetGetBenchmark
.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,14 +14,11 @@
* limitations under the License.
*/
package
zio.redis.benchmarks
.strings
package
zio.redis.benchmarks
import
cats.instances.list._
import
cats.syntax.foldable._
import
io.chrisdavenport.rediculous.
{
RedisCommands
,
RedisIO
}
import
cats.syntax.parallel._
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
...
...
@@ -32,35 +29,52 @@ import java.util.concurrent.TimeUnit
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
IncrBenchmarks
extends
BenchmarkRuntime
{
class
SetGetBenchmark
{
import
SetGetBenchmark._
@Param
(
Array
(
"
50
0"
))
var
count
:
Int
=
_
@Param
(
Array
(
"
2
0"
))
var
parallelism
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Param
(
Array
(
"500"
))
var
repetitions
:
Int
=
_
@Setup
(
Level
.
Trial
)
@Setup
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
)))
)
redis4Cats
=
Redis4Cats
.
unsafeMake
(
)
zioRedis
=
ZioRedis
.
unsafeMake
(
)
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
incr
[
Long
](
Key
.
unsafeFrom
(
i
)))))
@TearDown
def
tearDown
()
:
Unit
=
{
redis4Cats
.
tearDown
()
zioRedis
.
tearDown
()
}
@Benchmark
def
rediculous
()
:
Unit
=
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
append
[
RedisIO
](
i
,
i
).
run
(
c
)))
@Benchmark
def
redis4cats
()
:
Unit
=
execute
[
Redis4CatsClient
[
Long
]](
c
=>
items
.
traverse_
(
i
=>
c
.
incr
(
i
)))
redis4Cats
.
run
{
client
=>
val
task
=
client
.
set
(
TestKey
,
TestValue
)
>>
client
.
get
(
TestKey
)
val
tasks
=
List
.
fill
(
parallelism
)(
task
.
replicateA_
(
repetitions
))
tasks
.
parSequence_
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
incr
(
i
))))
def
zio
()
:
Unit
=
zioRedis
.
run
{
for
{
redis
<-
ZIO
.
service
[
Redis
]
task
=
redis
.
set
(
TestKey
,
TestValue
)
*>
redis
.
get
(
TestKey
).
returning
[
Long
]
tasks
=
Chunk
.
fill
(
parallelism
)(
task
.
repeatN
(
repetitions
))
_
<-
ZIO
.
collectAllParDiscard
(
tasks
)
}
yield
()
}
private
var
redis4Cats
:
Redis4Cats
=
_
private
var
zioRedis
:
ZioRedis
=
_
}
object
SetGetBenchmark
{
private
final
val
TestKey
=
"TestKey"
private
final
val
TestValue
=
1024L
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
BenchmarkRuntime
.scala
→
modules/benchmarks/src/main/scala/zio/redis/benchmarks/
ZioRedis
.scala
浏览文件 @
7dabd5b5
...
...
@@ -16,29 +16,29 @@
package
zio.redis.benchmarks
import
cats.effect.
{
IO
=>
CIO
}
import
zio._
import
zio.redis._
import
zio.schema.
Schema
import
zio.schema.
_
import
zio.schema.codec.
{
BinaryCodec
,
ProtobufCodec
}
trait
BenchmarkRuntime
{
final
def
execute
(
query
:
ZIO
[
Redis
,
RedisError
,
Unit
])
:
Unit
=
Unsafe
.
unsafe
{
implicit
unsafe
=>
Runtime
.
default
.
unsafe
.
run
(
query
.
provideLayer
(
BenchmarkRuntime
.
Layer
)).
getOrThrowFiberFailure
()
}
private
[
benchmarks
]
final
class
ZioRedis
private
(
runtime
:
Runtime.Scoped
[
Redis
])
{
def
run
(
program
:
ZIO
[
Redis
,
RedisError
,
Unit
])
:
Unit
=
Unsafe
.
unsafe
(
implicit
u
=>
runtime
.
unsafe
.
run
(
program
).
getOrThrow
())
final
def
execute
[
Client:
QueryRunner
](
query
:
Client
=>
CIO
[
Unit
]
)
:
Unit
=
QueryRunner
[
Client
].
unsafeRunWith
(
query
)
def
tearDown
(
)
:
Unit
=
Unsafe
.
unsafe
(
implicit
u
=>
runtime
.
unsafe
.
shutdown
()
)
}
object
BenchmarkRuntime
{
private
final
val
Layer
=
ZLayer
.
make
[
Redis
](
SingleNodeExecutor
.
local
,
ZLayer
.
succeed
[
CodecSupplier
](
new
CodecSupplier
{
def
get
[
A:
Schema
]
:
BinaryCodec
[
A
]
=
ProtobufCodec
.
protobufCodec
}),
Redis
.
layer
)
private
[
benchmarks
]
object
ZioRedis
{
def
unsafeMake
()
:
ZioRedis
=
{
val
runtime
=
Unsafe
.
unsafe
(
implicit
u
=>
Runtime
.
unsafe
.
fromLayer
(
TestLayer
))
new
ZioRedis
(
runtime
)
}
private
object
ProtobufCodecSupplier
extends
CodecSupplier
{
def
get
[
A:
Schema
]
:
BinaryCodec
[
A
]
=
ProtobufCodec
.
protobufCodec
}
private
final
val
TestLayer
=
ZLayer
.
make
[
Redis
](
Redis
.
local
,
ZLayer
.
succeed
(
ProtobufCodecSupplier
))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HDelBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HDelBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hdel
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hdel
[
RedisIO
](
key
,
List
(
it
.
_1
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hDel
(
key
,
it
.
_1
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hDel
(
key
,
it
.
_1
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HExistsBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HExistsBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hexists
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hexists
[
RedisIO
](
key
,
it
.
_1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hExists
(
key
,
it
.
_1
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hExists
(
key
,
it
.
_1
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HGetAllBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HGetAllBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
hgetall
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
hgetall
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
hGetAll
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hGetAll
(
key
).
returning
[
String
,
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HGetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HGetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hget
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hget
[
RedisIO
](
key
,
it
.
_1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hGet
(
key
,
it
.
_1
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hGet
(
key
,
it
.
_1
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HIncrbyBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HIncrbyBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
@Param
(
Array
(
"1"
))
var
increment
:
Long
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
cats.implicits.toFoldableOps
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hincrby
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
),
NonZeroLong
.
unsafeFrom
(
increment
)))
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hincrby
[
RedisIO
](
key
,
it
.
_1
,
increment
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
Long
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hIncrBy
(
key
,
it
.
_1
,
increment
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hIncrBy
(
key
,
it
.
_1
,
increment
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HIncrbyFloatBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HIncrbyFloatBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
@Param
(
Array
(
"1.0"
))
var
increment
:
Double
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hincrby
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
),
NonZeroDouble
.
unsafeFrom
(
increment
)))
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hincrbyfloat
[
RedisIO
](
key
,
it
.
_1
,
increment
).
run
(
c
))
)
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
Long
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hIncrByFloat
(
key
,
it
.
_1
,
increment
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hIncrByFloat
(
key
,
it
.
_1
,
increment
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HKeysBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HKeysBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
hkeys
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
hkeys
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
hKeys
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hKeys
(
key
).
returning
[
String
])))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HLenBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HLenBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
hlen
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
hlen
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
hLen
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hLen
(
key
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HMGetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HMGetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hmget
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hmget
[
RedisIO
](
key
,
List
(
it
.
_1
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hmGet
(
key
,
it
.
_1
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hmGet
(
key
,
it
.
_1
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HMSetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HMSetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hmset
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
),
it
.
_2
)))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hmset
[
RedisIO
](
key
,
List
(
it
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hmSet
(
key
,
Map
(
it
.
_1
->
it
.
_2
))
:
@annotation.nowarn
))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hmSet
(
key
,
it
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HSetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HSetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hset
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
),
it
.
_2
)))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hset
[
RedisIO
](
key
,
it
.
_1
,
it
.
_2
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hSet
(
key
,
it
.
_1
,
it
.
_2
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
it
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HSetNxBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HSetNxBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
// zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit)
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hsetnx
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
),
it
.
_2
)))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hsetnx
[
RedisIO
](
key
,
it
.
_1
,
it
.
_2
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hSetNx
(
key
,
it
.
_1
,
it
.
_2
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSetNx
(
key
,
it
.
_1
,
it
.
_2
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HStrLenBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HStrLenBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
it
=>
c
.
send
(
cmd
.
hstrlen
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
it
.
_1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
it
=>
RedisCommands
.
hstrlen
[
RedisIO
](
key
,
it
.
_1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
it
=>
c
.
hStrLen
(
key
,
it
.
_1
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
it
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hStrLen
(
key
,
it
.
_1
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/hash/HValsBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.hash
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
HValsBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
size
:
Int
=
_
private
var
items
:
List
[(
String
,
String
)]
=
_
private
val
key
=
"test-hash"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
size
).
map
(
e
=>
e
.
toString
->
e
.
toString
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hSet
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.implicits.toFoldableOps
import
cats.instances.list._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
hvals
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
hvals
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
hVals
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
hVals
(
key
).
returning
[
String
])))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BlMoveBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
BlMoveBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
blMove
(
key
,
key
,
Side
.
Left
,
Side
.
Right
,
1.
second
).
returning
[
String
])
)
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BlPopBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
BlPopBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
blocking
.
blpop
[
String
](
Key
.
unsafeFrom
(
key
),
PosInt
.
unsafeFrom
(
1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
blpop
[
RedisIO
](
List
(
key
),
1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.data._
import
cats.instances.list._
import
cats.syntax.foldable._
import
scala.concurrent.duration._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
blPop
(
Duration
(
1
,
TimeUnit
.
SECONDS
),
NonEmptyList
.
one
(
key
)))
)
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
blPop
(
key
)(
1.
second
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BrPopBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
BrPopBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
blocking
.
brpop
[
String
](
Key
.
unsafeFrom
(
key
),
PosInt
.
unsafeFrom
(
1
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
brpop
[
RedisIO
](
List
(
key
),
1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.data._
import
cats.instances.list._
import
cats.syntax.foldable._
import
scala.concurrent.duration._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
brPop
(
Duration
(
1
,
TimeUnit
.
SECONDS
),
NonEmptyList
.
one
(
key
)))
)
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
brPop
(
key
)(
1.
second
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/BrPopLPushBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
BrPopLPushBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
blocking
.
brpoplpush
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
key
),
PosInt
.
unsafeFrom
(
1
))
)
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
brpoplpush
[
RedisIO
](
key
,
key
,
1
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
import
scala.concurrent.duration._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
brPopLPush
(
Duration
(
1
,
TimeUnit
.
SECONDS
),
key
,
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
brPopLPush
(
key
,
key
,
1.
second
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LIndexBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LIndexBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
Int
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lindex
[
String
](
Key
.
unsafeFrom
(
key
),
Index
.
unsafeFrom
(
i
.
toLong
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lindex
[
RedisIO
](
key
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lIndex
(
key
,
i
.
toLong
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lIndex
(
key
,
i
.
toLong
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LInsertBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LInsertBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Invocation
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
_root_.laserdisc.lists.listtypes._
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
linsert
[
String
](
Key
.
unsafeFrom
(
key
),
ListPosition
.
before
,
i
,
i
)))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
linsertbefore
[
RedisIO
](
key
,
i
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lInsertBefore
(
key
,
i
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lInsert
[
String
,
String
](
key
,
Position
.
Before
,
i
,
i
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LLenBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LLenBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
llen
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
llen
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
lLen
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lLen
[
String
](
key
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPopBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LPopBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
lpop
[
String
](
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
lpop
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
lPop
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lPop
(
key
).
returning
[
String
])))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPosCountBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LPosCountBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lPosCount
[
String
,
String
](
key
,
i
,
Count
(
0L
))))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPushBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LPushBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
@TearDown
(
Level
.
Invocation
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lpush
[
String
](
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lpush
[
RedisIO
](
key
,
List
(
i
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lPush
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lPush
[
String
,
String
](
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPushXBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LPushXBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
).
unit
))
}
@TearDown
(
Level
.
Invocation
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lpushx
[
String
](
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lpushx
[
RedisIO
](
key
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lPushX
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lPushX
[
String
,
String
](
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LRangeBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LRangeBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"400"
))
var
count
:
Int
=
_
private
var
items
:
List
[
Int
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lrange
[
String
](
Key
.
unsafeFrom
(
key
),
Index
(
0L
),
Index
.
unsafeFrom
(
i
.
toLong
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lrange
[
RedisIO
](
key
,
0L
,
i
.
toLong
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lRange
(
key
,
0L
,
i
.
toLong
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lRange
(
key
,
0
to
i
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LRemBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LRemBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lrem
[
String
](
Key
.
unsafeFrom
(
key
),
Index
(
0
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lrem
[
RedisIO
](
key
,
0
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lRem
(
key
,
0
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lRem
[
String
](
key
,
0
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LSetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LSetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
Long
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toLong
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
lset
[
String
](
Key
.
unsafeFrom
(
key
),
Index
.
unsafeFrom
(
i
),
i
.
toString
)))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
lset
[
RedisIO
](
key
,
i
,
i
.
toString
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lSet
(
key
,
i
,
i
.
toString
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lSet
[
String
,
String
](
key
,
i
,
i
.
toString
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/LTrimBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LTrimBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
Int
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
count
to
0
by
-
1
).
toList
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
ltrim
(
Key
.
unsafeFrom
(
key
),
Index
(
1L
),
Index
.
unsafeFrom
(
i
.
toLong
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
ltrim
[
RedisIO
](
key
,
1L
,
i
.
toLong
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
lTrim
(
key
,
1L
,
i
.
toLong
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lTrim
[
String
](
key
,
1
to
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPopBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
RPopBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
rpop
[
String
](
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
rpop
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
rPop
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPop
(
key
).
returning
[
String
])))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPopLPushBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
RPopLPushBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
rpoplpush
[
String
](
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
key
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
rpoplpush
[
RedisIO
](
key
,
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
rPopLPush
(
key
,
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPopLPush
(
key
,
key
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPushBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
RPushBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
@TearDown
(
Level
.
Invocation
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
rpush
[
String
](
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
rpush
[
RedisIO
](
key
,
List
(
i
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
rPush
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
[
String
,
String
](
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/lists/RPushXBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.lists
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
RPushXBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Invocation
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
).
unit
))
}
@TearDown
(
Level
.
Invocation
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
rpushx
[
String
](
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
rpushx
[
RedisIO
](
key
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
rPushX
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPushX
[
String
,
String
](
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SAddBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SAddBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
sadd
(
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
sadd
[
RedisIO
](
key
,
List
(
i
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
sAdd
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SCardBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SCardBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
scard
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
scard
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sCard
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sCard
(
key
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SDiffBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SDiffBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
_root_.laserdisc.fs2._
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sdiff
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
otherKey
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sdiff
[
RedisIO
](
List
(
key
,
otherKey
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sDiff
(
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sDiff
(
key
,
otherKey
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SDiffStoreBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SDiffStoreBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
private
val
destinationKey
=
"test-set3"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sdiffstore
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
otherKey
),
Key
.
unsafeFrom
(
destinationKey
)))
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sdiffstore
[
RedisIO
](
destinationKey
,
List
(
key
,
otherKey
)).
run
(
c
))
)
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sDiffStore
(
destinationKey
,
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sDiffStore
(
destinationKey
,
key
,
otherKey
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SInterBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SInterBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sinter
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
otherKey
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sinter
[
RedisIO
](
List
(
key
,
otherKey
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sInter
(
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sInter
(
key
,
otherKey
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SInterStoreBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SInterStoreBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
private
val
destinationKey
=
"test-set3"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sinterstore
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
otherKey
),
Key
.
unsafeFrom
(
destinationKey
)))
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sinterstore
[
RedisIO
](
destinationKey
,
List
(
key
,
otherKey
)).
run
(
c
))
)
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sInterStore
(
destinationKey
,
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sInterStore
(
destinationKey
,
key
,
otherKey
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SIsMemberBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SIsMemberBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
sismember
(
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
sismember
[
RedisIO
](
key
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
sIsMember
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sIsMember
(
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SMembersBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SMembersBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
_root_.laserdisc.fs2._
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
smembers
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
smembers
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sMembers
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sMembers
(
key
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SMoveBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SMoveBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
destinationKey
=
"test-set2"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
smove
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
destinationKey
),
Key
.
unsafeFrom
(
i
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
smove
[
RedisIO
](
key
,
destinationKey
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
sMove
(
key
,
destinationKey
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sMove
(
key
,
destinationKey
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SPopBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SPopBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
spop
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
spop
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sPop
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sPop
(
key
).
returning
[
String
])))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SRandMemberBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SRandMemberBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
srandmember
(
Key
.
unsafeFrom
(
key
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
srandmember
[
RedisIO
](
key
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sRandMember
(
key
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sRandMember
(
key
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SRemBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SRemBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-set"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
srem
(
Key
.
unsafeFrom
(
key
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
srem
[
RedisIO
](
key
,
List
(
i
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
sRem
(
key
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sRem
(
key
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SUnionBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SUnionBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sunion
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
otherKey
))))
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sunion
[
RedisIO
](
List
(
key
,
otherKey
)).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sUnion
(
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sUnion
(
key
,
otherKey
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/sets/SUnionStoreBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.sets
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SUnionStoreBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
var
otherItems
:
List
[
String
]
=
_
private
val
key
=
"test-set1"
private
val
otherKey
=
"test-set2"
private
val
destinationKey
=
"test-set3"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
otherItems
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sAdd
(
otherKey
,
otherItems
.
head
,
otherItems
.
tail
:
_
*
).
unit
))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
_
=>
c
.
send
(
cmd
.
sunionstore
(
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
key
),
Key
.
unsafeFrom
(
destinationKey
)))
)
)
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
_
=>
RedisCommands
.
sunionstore
[
RedisIO
](
destinationKey
,
List
(
key
,
otherKey
)).
run
(
c
))
)
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
_
=>
c
.
sUnionStore
(
destinationKey
,
key
,
otherKey
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
_
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
sUnionStore
(
destinationKey
,
key
,
otherKey
)))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/AppendBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
cats.instances.list._
import
cats.syntax.foldable._
import
io.chrisdavenport.rediculous.
{
RedisCommands
,
RedisIO
}
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
AppendBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
append
(
Key
.
unsafeFrom
(
i
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
append
[
RedisIO
](
i
,
i
).
run
(
c
)))
@Benchmark
def
redis4cats
()
:
Unit
=
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
append
(
i
,
i
)))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
append
(
i
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/DecrBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
cats.instances.list._
import
cats.syntax.foldable._
import
io.chrisdavenport.rediculous.
{
RedisCommands
,
RedisIO
}
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
DecrBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
decr
[
Long
](
Key
.
unsafeFrom
(
i
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
decr
[
RedisIO
](
i
).
run
(
c
)))
@Benchmark
def
redis4cats
()
:
Unit
=
execute
[
Redis4CatsClient
[
Long
]](
c
=>
items
.
traverse_
(
i
=>
c
.
decr
(
i
)))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
decr
(
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/GetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
cats.instances.list._
import
cats.syntax.foldable._
import
io.chrisdavenport.rediculous.
{
RedisCommands
,
RedisIO
}
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
GetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
get
[
String
](
Key
.
unsafeFrom
(
i
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
get
[
RedisIO
](
i
).
run
(
c
)))
@Benchmark
def
redis4cats
()
:
Unit
=
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
get
(
i
)))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
redis
=>
ZIO
.
foreachDiscard
(
items
)(
redis
.
get
(
_
).
returning
[
String
]))
)
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/GetBitBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
cats.instances.list._
import
cats.syntax.foldable._
import
io.chrisdavenport.rediculous.
{
RedisCommands
,
RedisIO
}
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
GetBitBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
getbit
(
Key
.
unsafeFrom
(
i
),
PosLong
.
unsafeFrom
(
0L
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
getbit
[
RedisIO
](
i
,
0L
).
run
(
c
)))
@Benchmark
def
redis4cats
()
:
Unit
=
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
getBit
(
i
,
0L
)))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
getBit
(
i
,
0L
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/SetBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
SetBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
set
(
Key
.
unsafeFrom
(
i
),
i
))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
set
[
RedisIO
](
i
,
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
set
(
i
,
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
modules/benchmarks/src/main/scala/zio/redis/benchmarks/strings/StrLenBenchmarks.scala
已删除
100644 → 0
浏览文件 @
0111c534
/*
* 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.benchmarks.strings
import
org.openjdk.jmh.annotations._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
java.util.concurrent.TimeUnit
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
StrLenBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
set
(
i
,
i
))))
}
@Benchmark
def
laserdisc
()
:
Unit
=
{
import
_root_.laserdisc.fs2._
import
_root_.laserdisc.
{
all
=>
cmd
,
_
}
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
LaserDiscClient
](
c
=>
items
.
traverse_
(
i
=>
c
.
send
(
cmd
.
strlen
(
Key
.
unsafeFrom
(
i
)))))
}
@Benchmark
def
rediculous
()
:
Unit
=
{
import
cats.implicits._
import
io.chrisdavenport.rediculous._
execute
[
RediculousClient
](
c
=>
items
.
traverse_
(
i
=>
RedisCommands
.
strlen
[
RedisIO
](
i
).
run
(
c
)))
}
@Benchmark
def
redis4cats
()
:
Unit
=
{
import
cats.instances.list._
import
cats.syntax.foldable._
execute
[
Redis4CatsClient
[
String
]](
c
=>
items
.
traverse_
(
i
=>
c
.
strLen
(
i
)))
}
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
redis
=>
ZIO
.
foreachDiscard
(
items
)(
redis
.
strLen
[
String
])))
}
modules/embedded/src/test/scala/zio/redis/embedded/EmbeddedRedisSpec.scala
浏览文件 @
7dabd5b5
...
...
@@ -43,11 +43,10 @@ object EmbeddedRedisSpec extends ZIOSpecDefault {
}
).
provideShared
(
EmbeddedRedis
.
layer
,
SingleNodeExecutor
.
layer
,
ZLayer
.
succeed
[
CodecSupplier
](
new
CodecSupplier
{
def
get
[
A:
Schema
]
:
BinaryCodec
[
A
]
=
ProtobufCodec
.
protobufCodec
}),
Redis
.
layer
Redis
.
singleNode
)
@@
TestAspect
.
silentLogging
}
modules/example/src/main/scala/example/Main.scala
浏览文件 @
7dabd5b5
...
...
@@ -33,8 +33,7 @@ object Main extends ZIOAppDefault {
AppConfig
.
layer
,
ContributorsCache
.
layer
,
HttpClientZioBackend
.
layer
(),
Redis
.
layer
,
SingleNodeExecutor
.
layer
,
Redis
.
singleNode
,
ZLayer
.
succeed
[
CodecSupplier
](
new
CodecSupplier
{
def
get
[
A:
Schema
]
:
BinaryCodec
[
A
]
=
ProtobufCodec
.
protobufCodec
})
...
...
modules/redis/src/main/scala/zio/redis/Input.scala
浏览文件 @
7dabd5b5
...
...
@@ -161,6 +161,11 @@ object Input {
}
}
case
object
ClientTypeInput
extends
Input
[
ClientType
]
{
def
encode
(
data
:
ClientType
)
:
RespCommand
=
RespCommand
(
RespCommandArgument
.
Literal
(
"TYPE"
),
RespCommandArgument
.
Literal
(
data
.
asString
))
}
case
object
ClientPauseModeInput
extends
Input
[
ClientPauseMode
]
{
def
encode
(
data
:
ClientPauseMode
)
:
RespCommand
=
RespCommand
(
RespCommandArgument
.
Literal
(
data
.
asString
))
...
...
@@ -652,6 +657,15 @@ object Input {
RespCommand
(
RespCommandArgument
.
Literal
(
"ID"
),
RespCommandArgument
.
Unknown
(
data
.
toString
))
}
case
object
IdsInput
extends
Input
[(
Long
,
List
[
Long
])]
{
def
encode
(
data
:
(
Long
,
List
[
Long
]))
:
RespCommand
=
RespCommand
(
Chunk
.
fromIterable
(
RespCommandArgument
.
Literal
(
"ID"
)
+:
(
data
.
_1
::
data
.
_2
).
map
(
id
=>
RespCommandArgument
.
Unknown
(
id
.
toString
))
)
)
}
case
object
UnblockBehaviorInput
extends
Input
[
UnblockBehavior
]
{
def
encode
(
data
:
UnblockBehavior
)
:
RespCommand
=
RespCommand
(
RespCommandArgument
.
Unknown
(
data
.
asString
))
...
...
modules/redis/src/main/scala/zio/redis/Output.scala
浏览文件 @
7dabd5b5
...
...
@@ -727,10 +727,26 @@ object Output {
}
}
case
object
ClientInfoOutput
extends
Output
[
ClientInfo
]
{
protected
def
tryDecode
(
respValue
:
RespValue
)
:
ClientInfo
=
respValue
match
{
case
RespValue
.
BulkString
(
s
)
=>
ClientInfo
.
from
(
s
.
asString
)
case
other
=>
throw
ProtocolError
(
s
"$other isn't a bulk string"
)
}
}
case
object
ClientListOutput
extends
Output
[
Chunk
[
ClientInfo
]]
{
protected
def
tryDecode
(
respValue
:
RespValue
)
:
Chunk
[
ClientInfo
]
=
respValue
match
{
case
RespValue
.
BulkString
(
s
)
=>
ClientInfo
.
from
(
s
.
asString
.
split
(
"\r\n"
).
filter
(
_
.
nonEmpty
))
case
other
=>
throw
ProtocolError
(
s
"$other isn't a bulk string"
)
}
}
case
object
ClientTrackingInfoOutput
extends
Output
[
ClientTrackingInfo
]
{
protected
def
tryDecode
(
respValue
:
RespValue
)
:
ClientTrackingInfo
=
respValue
match
{
case
RespValue
.
NullArray
=>
throw
ProtocolError
(
s
"Array must not be empty"
)
case
RespValue
.
NullArray
=>
throw
ProtocolError
(
"Array must not be empty"
)
case
RespValue
.
Array
(
values
)
if
values
.
length
%
2
==
0
=>
val
fields
=
values
.
toList
.
grouped
(
2
)
...
...
modules/redis/src/main/scala/zio/redis/Redis.scala
浏览文件 @
7dabd5b5
...
...
@@ -17,6 +17,7 @@
package
zio.redis
import
zio._
import
zio.redis.internal._
trait
Redis
extends
api
.
Connection
...
...
@@ -33,7 +34,16 @@ trait Redis
with
api
.
Cluster
object
Redis
{
lazy
val
layer
:
URLayer
[
RedisExecutor
with
CodecSupplier
,
Redis
]
=
lazy
val
cluster
:
ZLayer
[
CodecSupplier
&
RedisClusterConfig
,
RedisError
,
Redis
]
=
ClusterExecutor
.
layer
>>>
makeLayer
lazy
val
local
:
ZLayer
[
CodecSupplier
,
RedisError.IOError
,
Redis
]
=
SingleNodeExecutor
.
local
>>>
makeLayer
lazy
val
singleNode
:
ZLayer
[
CodecSupplier
&
RedisConfig
,
RedisError.IOError
,
Redis
]
=
SingleNodeExecutor
.
layer
>>>
makeLayer
private
def
makeLayer
:
URLayer
[
CodecSupplier
&
RedisExecutor
,
Redis
]
=
ZLayer
{
for
{
codecSupplier
<-
ZIO
.
service
[
CodecSupplier
]
...
...
modules/redis/src/main/scala/zio/redis/api/Cluster.scala
浏览文件 @
7dabd5b5
...
...
@@ -20,7 +20,7 @@ import zio.redis.Input._
import
zio.redis.Output.
{
ChunkOutput
,
ClusterPartitionOutput
,
UnitOutput
}
import
zio.redis._
import
zio.redis.api.Cluster.
{
AskingCommand
,
ClusterSetSlots
,
ClusterSlots
}
import
zio.redis.internal.
{
RedisCommand
,
RedisEnvironment
}
import
zio.redis.internal.
{
RedisCommand
,
RedisEnvironment
,
RedisExecutor
}
import
zio.redis.options.Cluster.SetSlotSubCommand._
import
zio.redis.options.Cluster.
{
Partition
,
Slot
}
import
zio.
{
Chunk
,
IO
}
...
...
modules/redis/src/main/scala/zio/redis/api/Connection.scala
浏览文件 @
7dabd5b5
...
...
@@ -91,6 +91,19 @@ trait Connection extends RedisEnvironment {
command
.
run
(())
}
/**
* The command returns information and statistics about the current client connection in a mostly human readable
* format.
*
* @return
* information and statistics about the current client
*/
final
def
clientInfo
:
IO
[
RedisError
,
ClientInfo
]
=
{
val
command
=
RedisCommand
(
ClientInfo
,
NoInput
,
ClientInfoOutput
,
executor
)
command
.
run
(())
}
/**
* Closes a given client connection with the specified address
*
...
...
@@ -131,6 +144,32 @@ trait Connection extends RedisEnvironment {
command
.
run
(
filters
)
}
/**
* The command returns information and statistics about the client connections server in a mostly human readable
* format.
*
* @param clientType
* filters the list by client's type
* @param clientIds
* filters the list by client IDs
* @return
* a chunk of information and statistics about clients
*/
final
def
clientList
(
clientType
:
Option
[
ClientType
]
=
None
,
clientIds
:
Option
[(
Long
,
List
[
Long
])]
=
None
)
:
IO
[
RedisError
,
Chunk
[
ClientInfo
]]
=
{
val
command
=
RedisCommand
(
ClientList
,
Tuple2
(
OptionalInput
(
ClientTypeInput
),
OptionalInput
(
IdsInput
)),
ClientListOutput
,
executor
)
command
.
run
((
clientType
,
clientIds
))
}
/**
* Returns the name of the current connection as set by clientSetName
*
...
...
@@ -351,7 +390,9 @@ private[redis] object Connection {
final
val
Auth
=
"AUTH"
final
val
ClientCaching
=
"CLIENT CACHING"
final
val
ClientId
=
"CLIENT ID"
final
val
ClientInfo
=
"CLIENT INFO"
final
val
ClientKill
=
"CLIENT KILL"
final
val
ClientList
=
"CLIENT LIST"
final
val
ClientGetName
=
"CLIENT GETNAME"
final
val
ClientGetRedir
=
"CLIENT GETREDIR"
final
val
ClientUnpause
=
"CLIENT UNPAUSE"
...
...
modules/
benchmarks/src/main/scala/zio/redis/benchmarks/lists/LPosBenchmarks
.scala
→
modules/
redis/src/main/scala/zio/redis/internal/ClusterConnection
.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,39 +14,19 @@
* limitations under the License.
*/
package
zio.redis.
benchmarks.lists
package
zio.redis.
internal
import
org.openjdk.jmh.annotations
._
import
zio
._
import
zio.redis._
import
zio.redis.benchmarks._
import
zio.
{
Scope
=>
_
,
_
}
import
zio.redis.options.Cluster.
{
Partition
,
Slot
}
import
java.util.concurrent.TimeUnit
private
[
redis
]
final
case
class
ClusterConnection
(
partitions
:
Chunk
[
Partition
],
executors
:
Map
[
RedisUri
,
ExecutorScope
],
slots
:
Map
[
Slot
,
RedisUri
]
)
{
def
executor
(
slot
:
Slot
)
:
Option
[
RedisExecutor
]
=
executors
.
get
(
slots
(
slot
)).
map
(
_
.
executor
)
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Array
(
Mode
.
Throughput
))
@OutputTimeUnit
(
TimeUnit
.
SECONDS
)
@Measurement
(
iterations
=
15
)
@Warmup
(
iterations
=
15
)
@Fork
(
2
)
class
LPosBenchmarks
extends
BenchmarkRuntime
{
@Param
(
Array
(
"500"
))
var
count
:
Int
=
_
private
var
items
:
List
[
String
]
=
_
private
val
key
=
"test-list"
@Setup
(
Level
.
Trial
)
def
setup
()
:
Unit
=
{
items
=
(
0
to
count
).
toList
.
map
(
_
.
toString
)
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
rPush
(
key
,
items
.
head
,
items
.
tail
:
_
*
).
unit
))
}
@TearDown
(
Level
.
Trial
)
def
tearDown
()
:
Unit
=
execute
(
ZIO
.
serviceWithZIO
[
Redis
](
_
.
del
(
key
).
unit
))
@Benchmark
def
zio
()
:
Unit
=
execute
(
ZIO
.
foreachDiscard
(
items
)(
i
=>
ZIO
.
serviceWithZIO
[
Redis
](
_
.
lPos
[
String
,
String
](
key
,
i
))))
def
addExecutor
(
uri
:
RedisUri
,
es
:
ExecutorScope
)
:
ClusterConnection
=
copy
(
executors
=
executors
+
(
uri
->
es
))
}
modules/redis/src/main/scala/zio/redis/ClusterExecutor.scala
→
modules/redis/src/main/scala/zio/redis/
internal/
ClusterExecutor.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,22 +14,23 @@
* limitations under the License.
*/
package
zio.redis
package
zio.redis
.internal
import
zio._
import
zio.redis.
ClusterExecutor.
_
import
zio.redis._
import
zio.redis.api.Cluster.AskingCommand
import
zio.redis.internal.
{
RedisConnection
,
RespCommand
,
RespCommandArgument
,
RespValue
}
import
zio.redis.options.Cluster._
import
java.io.IOException
final
class
ClusterExecutor
private
(
private
[
redis
]
final
class
ClusterExecutor
private
(
clusterConnection
:
Ref.Synchronized
[
ClusterConnection
],
config
:
RedisClusterConfig
,
scope
:
Scope.Closeable
)
extends
RedisExecutor
{
import
ClusterExecutor._
def
execute
(
command
:
RespCommand
)
:
IO
[
RedisError
,
RespValue
]
=
{
def
execute
(
keySlot
:
Slot
)
=
...
...
@@ -93,7 +94,7 @@ final class ClusterExecutor private (
}
}
object
ClusterExecutor
{
private
[
redis
]
object
ClusterExecutor
{
lazy
val
layer
:
ZLayer
[
RedisClusterConfig
,
RedisError
,
RedisExecutor
]
=
ZLayer
.
scoped
{
...
...
@@ -106,7 +107,7 @@ object ClusterExecutor {
}
yield
executor
}
private
[
redis
]
def
create
(
def
create
(
config
:
RedisClusterConfig
,
scope
:
Scope.Closeable
)
:
ZIO
[
Scope
,
RedisError
,
ClusterExecutor
]
=
...
...
@@ -148,16 +149,15 @@ object ClusterExecutor {
_
<-
layerScope
.
addFinalizerExit
(
closableScope
.
close
(
_
))
}
yield
ExecutorScope
(
executor
,
closableScope
)
private
def
redis
(
address
:
RedisUri
)
=
{
val
executorLayer
=
ZLayer
.
succeed
(
RedisConfig
(
address
.
host
,
address
.
port
))
>>>
SingleNodeExecutor
.
layer
val
codecLayer
=
ZLayer
.
succeed
[
CodecSupplier
](
CodecSupplier
.
utf8
)
val
redisLayer
=
executorLayer
++
codecLayer
>>>
Redis
.
layer
private
def
redis
(
address
:
RedisUri
)
=
for
{
closableScope
<-
Scope
.
make
configLayer
=
ZLayer
.
succeed
(
RedisConfig
(
address
.
host
,
address
.
port
))
supplierLayer
=
ZLayer
.
succeed
(
CodecSupplier
.
utf8
)
redisLayer
=
ZLayer
.
make
[
Redis
](
configLayer
,
supplierLayer
,
Redis
.
singleNode
)
layer
<-
closableScope
.
extend
[
Any
](
redisLayer
.
memoize
)
_
<-
logScopeFinalizer
(
"Temporary redis connection is closed"
)
}
yield
(
layer
,
closableScope
)
}
private
def
slotAddress
(
partitions
:
Chunk
[
Partition
])
=
partitions
.
flatMap
{
p
=>
...
...
@@ -166,6 +166,7 @@ object ClusterExecutor {
private
final
val
CusterKeyExecutorError
=
RedisError
.
IOError
(
new
IOException
(
"Executor doesn't found. No way to dispatch this command to Redis Cluster"
))
private
final
val
CusterConnectionError
=
RedisError
.
IOError
(
new
IOException
(
"The connection to cluster has been failed. Can't reach a single startup node."
))
}
modules/redis/src/main/scala/zio/redis/internal/ExecutorScope.scala
0 → 100644
浏览文件 @
7dabd5b5
/*
* 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.internal
import
zio.Scope
private
[
redis
]
final
case
class
ExecutorScope
(
executor
:
RedisExecutor
,
scope
:
Scope.Closeable
)
modules/redis/src/main/scala/zio/redis/internal/RedisEnvironment.scala
浏览文件 @
7dabd5b5
...
...
@@ -16,7 +16,7 @@
package
zio.redis.internal
import
zio.redis.
{
CodecSupplier
,
RedisExecutor
}
import
zio.redis.
CodecSupplier
import
zio.schema.Schema
import
zio.schema.codec.BinaryCodec
...
...
modules/redis/src/main/scala/zio/redis/RedisExecutor.scala
→
modules/redis/src/main/scala/zio/redis/
internal/
RedisExecutor.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,11 +14,11 @@
* limitations under the License.
*/
package
zio.redis
package
zio.redis
.internal
import
zio.IO
import
zio.redis.
internal.
{
RespCommand
,
RespValue
}
import
zio.redis.
RedisError
trait
RedisExecutor
{
private
[
redis
]
def
execute
(
command
:
RespCommand
)
:
IO
[
RedisError
,
RespValue
]
private
[
redis
]
trait
RedisExecutor
{
def
execute
(
command
:
RespCommand
)
:
IO
[
RedisError
,
RespValue
]
}
modules/redis/src/main/scala/zio/redis/SingleNodeExecutor.scala
→
modules/redis/src/main/scala/zio/redis/
internal/
SingleNodeExecutor.scala
浏览文件 @
7dabd5b5
...
...
@@ -14,13 +14,13 @@
* limitations under the License.
*/
package
zio.redis
package
zio.redis
.internal
import
zio._
import
zio.redis.SingleNodeExecutor._
import
zio.redis.
internal.
{
RedisConnection
,
RespCommand
,
RespValue
}
import
zio.redis.
internal.
SingleNodeExecutor._
import
zio.redis.
{
RedisConfig
,
RedisError
}
final
class
SingleNodeExecutor
private
(
private
[
redis
]
final
class
SingleNodeExecutor
private
(
connection
:
RedisConnection
,
requests
:
Queue
[
Request
],
responses
:
Queue
[
Promise
[
RedisError
,
RespValue
]]
...
...
@@ -70,20 +70,14 @@ final class SingleNodeExecutor private (
}
object
SingleNodeExecutor
{
private
[
redis
]
object
SingleNodeExecutor
{
lazy
val
layer
:
ZLayer
[
RedisConfig
,
RedisError.IOError
,
RedisExecutor
]
=
RedisConnection
.
layer
>>>
makeLayer
lazy
val
local
:
ZLayer
[
Any
,
RedisError.IOError
,
RedisExecutor
]
=
RedisConnection
.
local
>>>
makeLayer
private
final
case
class
Request
(
command
:
Chunk
[
RespValue.BulkString
],
promise
:
Promise
[
RedisError
,
RespValue
])
private
final
val
True
:
Any
=>
Boolean
=
_
=>
true
private
final
val
RequestQueueSize
=
16
private
[
redis
]
def
create
(
connection
:
RedisConnection
)
:
URIO
[
Scope
,
SingleNodeExecutor
]
=
def
create
(
connection
:
RedisConnection
)
:
URIO
[
Scope
,
SingleNodeExecutor
]
=
for
{
requests
<-
Queue
.
bounded
[
Request
](
RequestQueueSize
)
responses
<-
Queue
.
unbounded
[
Promise
[
RedisError
,
RespValue
]]
...
...
@@ -92,6 +86,12 @@ object SingleNodeExecutor {
_
<-
logScopeFinalizer
(
s
"$executor Node Executor is closed"
)
}
yield
executor
private
final
case
class
Request
(
command
:
Chunk
[
RespValue.BulkString
],
promise
:
Promise
[
RedisError
,
RespValue
])
private
final
val
True
:
Any
=>
Boolean
=
_
=>
true
private
final
val
RequestQueueSize
=
16
private
def
makeLayer
:
ZLayer
[
RedisConnection
,
RedisError.IOError
,
RedisExecutor
]
=
ZLayer
.
scoped
(
ZIO
.
serviceWithZIO
[
RedisConnection
](
create
))
}
modules/
benchmarks/src/main/scala/zio/redis/benchmarks
/package.scala
→
modules/
redis/src/main/scala/zio/redis/internal
/package.scala
浏览文件 @
7dabd5b5
...
...
@@ -16,13 +16,16 @@
package
zio.redis
import
cats.effect.
{
IO
=>
CIO
}
import
dev.profunktor.redis4cats.RedisCommands
import
io.chrisdavenport.rediculous
import
laserdisc.fs2.RedisClient
import
zio._
package
object
internal
{
private
[
redis
]
def
logScopeFinalizer
(
msg
:
String
)
:
URIO
[
Scope
,
Unit
]
=
for
{
scope
<-
ZIO
.
scope
_
<-
scope
.
addFinalizerExit
{
case
Exit
.
Success
(
_
)
=>
ZIO
.
logTrace
(
s
"$msg with success"
)
case
Exit
.
Failure
(
th
)
=>
ZIO
.
logTraceCause
(
s
"$msg with failure"
,
th
)
}
}
yield
()
package
object
benchmarks
{
type
Redis4CatsClient
[
A
]
=
RedisCommands
[
CIO
,
String
,
A
]
type
LaserDiscClient
=
RedisClient
[
CIO
]
type
RediculousClient
=
rediculous
.
RedisConnection
[
CIO
]
}
modules/redis/src/main/scala/zio/redis/options/Cluster.scala
浏览文件 @
7dabd5b5
...
...
@@ -16,30 +16,16 @@
package
zio.redis.options
import
zio.
redis.
{
RedisExecutor
,
RedisUri
}
import
zio.
{
Chunk
,
Scope
}
import
zio.
Chunk
import
zio.
redis.RedisUri
object
Cluster
{
private
[
redis
]
final
val
SlotsAmount
=
16384
final
case
class
ExecutorScope
(
executor
:
RedisExecutor
,
scope
:
Scope.Closeable
)
final
case
class
ClusterConnection
(
partitions
:
Chunk
[
Partition
],
executors
:
Map
[
RedisUri
,
ExecutorScope
],
slots
:
Map
[
Slot
,
RedisUri
]
)
{
def
executor
(
slot
:
Slot
)
:
Option
[
RedisExecutor
]
=
executors
.
get
(
slots
(
slot
)).
map
(
_
.
executor
)
def
addExecutor
(
uri
:
RedisUri
,
es
:
ExecutorScope
)
:
ClusterConnection
=
copy
(
executors
=
executors
+
(
uri
->
es
))
}
final
case
class
Slot
(
number
:
Long
)
extends
AnyVal
object
Slot
{
val
Default
:
Slot
=
Slot
(
1
)
final
val
Default
:
Slot
=
Slot
(
1
)
}
final
case
class
Node
(
id
:
String
,
address
:
RedisUri
)
...
...
modules/redis/src/main/scala/zio/redis/options/Connection.scala
浏览文件 @
7dabd5b5
...
...
@@ -16,53 +16,67 @@
package
zio.redis.options
import
zio.
Duration
import
zio.
{
Chunk
,
Duration
}
import
java.net.InetAddress
import
scala.collection.compat._
trait
Connection
{
sealed
case
class
Address
(
ip
:
InetAddress
,
port
:
Int
)
{
private
[
redis
]
final
def
asString
:
String
=
s
"${ip.getHostAddress}:$port"
}
object
Address
{
private
[
redis
]
final
def
fromString
(
addr
:
String
)
:
Option
[
Address
]
=
addr
.
split
(
":"
).
toList
match
{
case
ip
::
port
::
Nil
=>
port
.
toIntOption
.
map
(
new
Address
(
InetAddress
.
getByName
(
ip
),
_
))
case
_
=>
None
}
}
sealed
case
class
ClientEvents
(
readable
:
Boolean
=
false
,
writable
:
Boolean
=
false
)
sealed
trait
ClientFlag
object
ClientFlag
{
case
object
ToBeClosedAsap
extends
ClientFlag
case
object
Blocked
extends
ClientFlag
case
object
ToBeClosedAfterReply
extends
ClientFlag
case
object
WatchedKeysModified
extends
ClientFlag
case
object
IsMaster
extends
ClientFlag
case
object
MonitorMode
extends
ClientFlag
case
object
PubSub
extends
ClientFlag
case
object
ReadOnlyMode
extends
ClientFlag
case
object
Replica
extends
ClientFlag
case
object
Unblocked
extends
ClientFlag
case
object
UnixDomainSocket
extends
ClientFlag
case
object
MultiExecContext
extends
ClientFlag
case
object
KeysTrackingEnabled
extends
ClientFlag
case
object
Blocked
extends
ClientFlag
case
object
BroadcastTrackingMode
extends
ClientFlag
case
object
IsMaster
extends
ClientFlag
case
object
KeysTrackingEnabled
extends
ClientFlag
case
object
MonitorMode
extends
ClientFlag
case
object
MultiExecContext
extends
ClientFlag
case
object
PubSub
extends
ClientFlag
case
object
ReadOnlyMode
extends
ClientFlag
case
object
Replica
extends
ClientFlag
case
object
ToBeClosedAfterReply
extends
ClientFlag
case
object
ToBeClosedAsap
extends
ClientFlag
case
object
TrackingTargetClientInvalid
extends
ClientFlag
case
object
BroadcastTrackingMode
extends
ClientFlag
case
object
Unblocked
extends
ClientFlag
case
object
UnixDomainSocket
extends
ClientFlag
case
object
WatchedKeysModified
extends
ClientFlag
private
[
redis
]
lazy
val
Flags
=
Map
(
'A'
->
ClientFlag
.
ToBeClosedAsap
,
'b'
->
ClientFlag
.
Blocked
,
'B'
->
ClientFlag
.
BroadcastTrackingMode
,
'c'
->
ClientFlag
.
ToBeClosedAfterReply
,
'd'
->
ClientFlag
.
WatchedKeysModified
,
'M'
->
ClientFlag
.
IsMaster
,
'O'
->
ClientFlag
.
MonitorMode
,
'P'
->
ClientFlag
.
PubSub
,
'r'
->
ClientFlag
.
ReadOnlyMode
,
'R'
->
ClientFlag
.
TrackingTargetClientInvalid
,
'S'
->
ClientFlag
.
Replica
,
't'
->
ClientFlag
.
KeysTrackingEnabled
,
'u'
->
ClientFlag
.
Unblocked
,
'U'
->
ClientFlag
.
UnixDomainSocket
,
'x'
->
ClientFlag
.
MultiExecContext
)
}
sealed
case
class
ClientInfo
(
id
:
Long
,
id
:
Option
[
Long
]
=
None
,
name
:
Option
[
String
]
=
None
,
address
:
Option
[
Address
]
=
None
,
localAddress
:
Option
[
Address
]
=
None
,
...
...
@@ -71,9 +85,9 @@ trait Connection {
idle
:
Option
[
Duration
]
=
None
,
flags
:
Set
[
ClientFlag
]
=
Set
.
empty
,
databaseId
:
Option
[
Long
]
=
None
,
subscriptions
:
Int
=
0
,
patternSubscriptions
:
Int
=
0
,
multiCommands
:
Int
=
0
,
subscriptions
:
Option
[
Int
]
=
None
,
patternSubscriptions
:
Option
[
Int
]
=
None
,
multiCommands
:
Option
[
Int
]
=
None
,
queryBufferLength
:
Option
[
Int
]
=
None
,
queryBufferFree
:
Option
[
Int
]
=
None
,
outputBufferLength
:
Option
[
Int
]
=
None
,
...
...
@@ -87,6 +101,42 @@ trait Connection {
user
:
Option
[
String
]
=
None
)
object
ClientInfo
{
private
[
redis
]
final
def
from
(
line
:
String
)
:
ClientInfo
=
{
val
data
=
line
.
trim
.
split
(
" "
).
map
(
_
.
split
(
"="
).
toList
).
collect
{
case
k
::
v
::
Nil
=>
k
->
v
}.
toMap
val
events
=
data
.
get
(
"events"
)
new
ClientInfo
(
id
=
data
.
get
(
"id"
).
flatMap
(
_
.
toLongOption
),
name
=
data
.
get
(
"name"
),
address
=
data
.
get
(
"addr"
).
flatMap
(
Address
.
fromString
),
localAddress
=
data
.
get
(
"laddr"
).
flatMap
(
Address
.
fromString
),
fileDescriptor
=
data
.
get
(
"fd"
).
flatMap
(
_
.
toLongOption
),
age
=
data
.
get
(
"age"
).
flatMap
(
_
.
toLongOption
).
map
(
Duration
.
fromSeconds
),
idle
=
data
.
get
(
"idle"
).
flatMap
(
_
.
toLongOption
).
map
(
Duration
.
fromSeconds
),
flags
=
data
.
get
(
"flags"
)
.
fold
(
Set
.
empty
[
ClientFlag
])(
_
.
foldLeft
(
Set
.
empty
[
ClientFlag
])((
fs
,
f
)
=>
fs
++
ClientFlag
.
Flags
.
get
(
f
))),
databaseId
=
data
.
get
(
"id"
).
flatMap
(
_
.
toLongOption
),
subscriptions
=
data
.
get
(
"sub"
).
flatMap
(
_
.
toIntOption
),
patternSubscriptions
=
data
.
get
(
"psub"
).
flatMap
(
_
.
toIntOption
),
multiCommands
=
data
.
get
(
"multi"
).
flatMap
(
_
.
toIntOption
),
queryBufferLength
=
data
.
get
(
"qbuf"
).
flatMap
(
_
.
toIntOption
),
queryBufferFree
=
data
.
get
(
"qbuf-free"
).
flatMap
(
_
.
toIntOption
),
outputListLength
=
data
.
get
(
"oll"
).
flatMap
(
_
.
toIntOption
),
outputBufferMem
=
data
.
get
(
"omem"
).
flatMap
(
_
.
toLongOption
),
events
=
ClientEvents
(
readable
=
events
.
exists
(
_
.
contains
(
"r"
)),
writable
=
events
.
exists
(
_
.
contains
(
"w"
))),
lastCommand
=
data
.
get
(
"cmd"
),
argvMemory
=
data
.
get
(
"argv-mem"
).
flatMap
(
_
.
toLongOption
),
totalMemory
=
data
.
get
(
"total-mem"
).
flatMap
(
_
.
toLongOption
),
redirectionClientId
=
data
.
get
(
"redir"
).
flatMap
(
_
.
toLongOption
),
user
=
data
.
get
(
"user"
)
)
}
private
[
redis
]
final
def
from
(
lines
:
Array
[
String
])
:
Chunk
[
ClientInfo
]
=
Chunk
.
fromArray
(
lines
.
map
(
from
))
}
sealed
trait
ClientKillFilter
object
ClientKillFilter
{
...
...
@@ -156,10 +206,10 @@ trait Connection {
sealed
trait
ClientType
{
self
=>
private
[
redis
]
final
def
asString
:
String
=
self
match
{
case
ClientType
.
Normal
=>
"
normal
"
case
ClientType
.
Master
=>
"
master
"
case
ClientType
.
Replica
=>
"
replica
"
case
ClientType
.
PubSub
=>
"
pubsub
"
case
ClientType
.
Normal
=>
"
NORMAL
"
case
ClientType
.
Master
=>
"
MASTER
"
case
ClientType
.
Replica
=>
"
REPLICA
"
case
ClientType
.
PubSub
=>
"
PUBSUB
"
}
}
...
...
modules/redis/src/main/scala/zio/redis/options/Streams.scala
浏览文件 @
7dabd5b5
...
...
@@ -61,8 +61,6 @@ trait Streams {
counter
:
Long
)
sealed
case
class
Group
[
G
,
C
](
group
:
G
,
consumer
:
C
)
case
object
NoAck
{
private
[
redis
]
def
asString
:
String
=
"NOACK"
}
...
...
modules/redis/src/main/scala/zio/redis/package.scala
浏览文件 @
7dabd5b5
...
...
@@ -28,13 +28,4 @@ package object redis
with
options
.
Scripting
{
type
Id
[
+A
]
=
A
private
[
redis
]
def
logScopeFinalizer
(
msg
:
String
)
:
URIO
[
Scope
,
Unit
]
=
for
{
scope
<-
ZIO
.
scope
_
<-
scope
.
addFinalizerExit
{
case
Exit
.
Success
(
_
)
=>
ZIO
.
logTrace
(
s
"$msg with success"
)
case
Exit
.
Failure
(
th
)
=>
ZIO
.
logTraceCause
(
s
"$msg with failure"
,
th
)
}
}
yield
()
}
modules/redis/src/test/scala/zio/redis/ApiSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
modules/redis/src/test/scala/zio/redis/ConnectionSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
modules/redis/src/test/scala/zio/redis/InputSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
modules/redis/src/test/scala/zio/redis/KeysSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
modules/redis/src/test/scala/zio/redis/SortedSetsSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
modules/redis/src/test/scala/zio/redis/ClusterExecutorSpec.scala
→
modules/redis/src/test/scala/zio/redis/
internal/
ClusterExecutorSpec.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。
project/BuildHelper.scala
浏览文件 @
7dabd5b5
此差异已折叠。
点击以展开。