Skip to content

Commit 204921b

Browse files
authored
Upgrade to ZIO 2.0.0-RC6 (#85)
* upgrade zio version * fix
1 parent 0456a75 commit 204921b

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ addCommandAlias(
3737
";zioCacheNative/test:compile"
3838
)
3939

40-
val zioVersion = "2.0.0-RC5"
40+
val zioVersion = "2.0.0-RC6"
4141

4242
lazy val root = project
4343
.in(file("."))

zio-cache-benchmarks/src/main/scala/zio/cache/ChurnBenchmark.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import java.util.concurrent.TimeUnit
1111
@Measurement(iterations = 5, timeUnit = TimeUnit.SECONDS, time = 3)
1212
@Warmup(iterations = 5, timeUnit = TimeUnit.SECONDS, time = 3)
1313
@Fork(1)
14-
class ChurnBenchmark extends zio.Runtime[ZEnv] {
15-
override def environment: ZEnvironment[ZEnv] = ZEnv.Services.live
16-
override def runtimeConfig: RuntimeConfig = RuntimeConfig.benchmark
14+
class ChurnBenchmark extends zio.Runtime[Any] {
15+
override def environment: ZEnvironment[Any] = ZEnvironment.empty
1716

1817
@Param(Array("10000"))
1918
var size: Int = _

zio-cache-benchmarks/src/main/scala/zio/cache/FillBenchmark.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import java.util.concurrent.TimeUnit
1111
@Measurement(iterations = 5, timeUnit = TimeUnit.SECONDS, time = 3)
1212
@Warmup(iterations = 5, timeUnit = TimeUnit.SECONDS, time = 3)
1313
@Fork(1)
14-
class FillBenchmark extends zio.Runtime[ZEnv] {
15-
override def environment: ZEnvironment[ZEnv] = ZEnv.Services.live
16-
override def runtimeConfig: RuntimeConfig = RuntimeConfig.benchmark
14+
class FillBenchmark extends zio.Runtime[Any] {
15+
override def environment: ZEnvironment[Any] = ZEnvironment.empty
1716

1817
@Param(Array("10000"))
1918
var size: Int = _

zio-cache/shared/src/main/scala/zio/cache/Cache.scala

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package zio.cache
22

33
import zio.internal.MutableConcurrentQueue
44
import zio.stacktracer.TracingImplicits.disableAutoTrace
5-
import zio.{Exit, IO, Promise, UIO, URIO, ZIO, ZTraceElement}
5+
import zio.{Exit, IO, Promise, Trace, UIO, URIO, ZIO}
66

77
import java.time.{Duration, Instant}
88
import java.util.Map
@@ -31,25 +31,25 @@ sealed abstract class Cache[-Key, +Error, +Value] {
3131
/**
3232
* Returns statistics for this cache.
3333
*/
34-
def cacheStats(implicit trace: ZTraceElement): UIO[CacheStats]
34+
def cacheStats(implicit trace: Trace): UIO[CacheStats]
3535

3636
/**
3737
* Returns whether a value associated with the specified key exists in the
3838
* cache.
3939
*/
40-
def contains(key: Key)(implicit trace: ZTraceElement): UIO[Boolean]
40+
def contains(key: Key)(implicit trace: Trace): UIO[Boolean]
4141

4242
/**
4343
* Returns statistics for the specified entry.
4444
*/
45-
def entryStats(key: Key)(implicit trace: ZTraceElement): UIO[Option[EntryStats]]
45+
def entryStats(key: Key)(implicit trace: Trace): UIO[Option[EntryStats]]
4646

4747
/**
4848
* Retrieves the value associated with the specified key if it exists.
4949
* Otherwise computes the value with the lookup function, puts it in the
5050
* cache, and returns it.
5151
*/
52-
def get(key: Key)(implicit trace: ZTraceElement): IO[Error, Value]
52+
def get(key: Key)(implicit trace: Trace): IO[Error, Value]
5353

5454
/**
5555
* Computes the value associated with the specified key, with the lookup
@@ -65,7 +65,7 @@ sealed abstract class Cache[-Key, +Error, +Value] {
6565
/**
6666
* Invalidates the value associated with the specified key.
6767
*/
68-
def invalidate(key: Key)(implicit trace: ZTraceElement): UIO[Unit]
68+
def invalidate(key: Key)(implicit trace: Trace): UIO[Unit]
6969

7070
/**
7171
* Invalidates all values in the cache.
@@ -75,7 +75,7 @@ sealed abstract class Cache[-Key, +Error, +Value] {
7575
/**
7676
* Returns the approximate number of values in the cache.
7777
*/
78-
def size(implicit trace: ZTraceElement): UIO[Int]
78+
def size(implicit trace: Trace): UIO[Int]
7979
}
8080

8181
object Cache {
@@ -88,7 +88,7 @@ object Cache {
8888
capacity: Int,
8989
timeToLive: Duration,
9090
lookup: Lookup[Key, Environment, Error, Value]
91-
)(implicit trace: ZTraceElement): URIO[Environment, Cache[Key, Error, Value]] =
91+
)(implicit trace: Trace): URIO[Environment, Cache[Key, Error, Value]] =
9292
makeWith(capacity, lookup)(_ => timeToLive)
9393

9494
/**
@@ -101,7 +101,7 @@ object Cache {
101101
lookup: Lookup[Key, Environment, Error, Value]
102102
)(
103103
timeToLive: Exit[Error, Value] => Duration
104-
)(implicit trace: ZTraceElement): URIO[Environment, Cache[Key, Error, Value]] =
104+
)(implicit trace: Trace): URIO[Environment, Cache[Key, Error, Value]] =
105105
ZIO.clock.flatMap { clock =>
106106
ZIO.environment[Environment].flatMap { environment =>
107107
ZIO.fiberId.map { fiberId =>
@@ -145,13 +145,13 @@ object Cache {
145145

146146
new Cache[Key, Error, Value] {
147147

148-
override def cacheStats(implicit trace: ZTraceElement): UIO[CacheStats] =
148+
override def cacheStats(implicit trace: Trace): UIO[CacheStats] =
149149
ZIO.succeed(CacheStats(hits.longValue, misses.longValue, map.size))
150150

151-
override def contains(k: Key)(implicit trace: ZTraceElement): UIO[Boolean] =
151+
override def contains(k: Key)(implicit trace: Trace): UIO[Boolean] =
152152
ZIO.succeed(map.containsKey(k))
153153

154-
override def entryStats(k: Key)(implicit trace: ZTraceElement): UIO[Option[EntryStats]] =
154+
override def entryStats(k: Key)(implicit trace: Trace): UIO[Option[EntryStats]] =
155155
ZIO.succeed {
156156
val value = map.get(k)
157157
if (value eq null) None
@@ -167,7 +167,7 @@ object Cache {
167167
}
168168
}
169169

170-
override def get(k: Key)(implicit trace: ZTraceElement): IO[Error, Value] =
170+
override def get(k: Key)(implicit trace: Trace): IO[Error, Value] =
171171
ZIO.suspendSucceed {
172172
var key: MapKey[Key] = null
173173
var promise: Promise[Error, Value] = null
@@ -241,7 +241,7 @@ object Cache {
241241
result.unit
242242
}
243243

244-
override def invalidate(k: Key)(implicit trace: ZTraceElement): UIO[Unit] =
244+
override def invalidate(k: Key)(implicit trace: Trace): UIO[Unit] =
245245
ZIO.succeed {
246246
map.remove(k)
247247
()
@@ -252,7 +252,7 @@ object Cache {
252252
map.clear()
253253
}
254254

255-
def size(implicit trace: ZTraceElement): UIO[Int] =
255+
def size(implicit trace: Trace): UIO[Int] =
256256
ZIO.succeed(map.size)
257257

258258
private def lookupValueOf(key: Key, promise: Promise[Error, Value]): IO[Error, Value] =

zio-cache/shared/src/test/scala/zio/cache/CacheSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object CacheSpec extends ZIOSpecDefault {
99
def hash(x: Int): Int => UIO[Int] =
1010
y => ZIO.succeed((x ^ y).hashCode)
1111

12-
def spec: ZSpec[Environment, Any] = suite("CacheSpec")(
12+
def spec: Spec[Environment, Any] = suite("CacheSpec")(
1313
test("cacheStats") {
1414
check(Gen.int) { salt =>
1515
for {

0 commit comments

Comments
 (0)