Skip to content

Commit

Permalink
use Scala 2.12.10 and 2.13.0, SBT 1.3.0, Cats 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-git committed Sep 11, 2019
1 parent 32f3027 commit 0b4400c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/main/scala/com/evolutiongaming/scache/Cache.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.evolutiongaming.scache

import cats.Applicative
import cats.{Applicative, Parallel}
import cats.effect.{Concurrent, Resource, Timer}
import cats.implicits._
import cats.temp.par.Par
import com.evolutiongaming.catshelper.Runtime
import com.evolutiongaming.smetrics.MeasureDuration

Expand Down Expand Up @@ -79,7 +78,7 @@ object Cache {
}


def expiring[F[_] : Concurrent : Timer : Runtime : Par, K, V](
def expiring[F[_] : Concurrent : Timer : Runtime : Parallel, K, V](
expireAfter: FiniteDuration,
maxSize: Option[Int] = None,
refresh: Option[ExpiringCache.Refresh[K, F[V]]] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object CacheMetered {
value <- value.attempt
duration <- duration
_ <- metrics.load(duration, value.isRight)
value <- value.raiseOrPure[F]
value <- value.liftTo[F]
} yield value
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/com/evolutiongaming/scache/ExpiringCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.evolutiongaming.scache
import cats.effect.concurrent.Ref
import cats.effect.{Clock, Concurrent, Resource, Timer}
import cats.implicits._
import cats.temp.par.{Par, _}
import cats.{Applicative, Monad, Parallel}
import com.evolutiongaming.catshelper.ClockHelper._
import com.evolutiongaming.catshelper.Schedule
Expand All @@ -19,7 +18,7 @@ object ExpiringCache {

type Timestamp = Long

private[scache] def of[F[_] : Concurrent : Timer : Par, K, V](
private[scache] def of[F[_] : Concurrent : Timer : Parallel, K, V](
expireAfter: FiniteDuration,
maxSize: Option[Int] = None,
refresh: Option[Refresh[K, F[V]]] = None,
Expand Down Expand Up @@ -231,8 +230,8 @@ object ExpiringCache {
for {
entries <- cache.values
} yield {
entries.mapValues { entry =>
for {
entries.map { case (key, entry) =>
key -> for {
entry <- entry
} yield {
entry.value
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/com/evolutiongaming/scache/LoadingCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ object LoadingCache {
}
case Left(_) => ref.update { _ - key }
}
_ <- deferred.complete(value.raiseOrPure[F])
value <- value.raiseOrPure[F]
_ <- deferred.complete(value.liftTo[F])
value <- value.liftTo[F]
} yield value
}

Expand Down Expand Up @@ -138,7 +138,7 @@ object LoadingCache {
for {
entryRefs <- ref.get
} yield {
entryRefs.mapValues(_.value)
entryRefs.map { case (k, v) => k -> v.value }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.evolutiongaming.scache

import cats.Monad
import cats.{Monad, Parallel}
import cats.effect.concurrent.Ref
import cats.effect.{Concurrent, IO, Timer}
import cats.implicits._
import cats.temp.par._
import com.evolutiongaming.scache.IOSuite._
import org.scalatest.{AsyncFunSuite, Matchers}

Expand Down Expand Up @@ -37,7 +36,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
refreshFails[IO].run()
}

private def expireRecords[F[_] : Concurrent : Timer : Par] = {
private def expireRecords[F[_] : Concurrent : Timer : Parallel] = {

ExpiringCache.of[F, Int, Int](100.millis).use { cache =>

Expand Down Expand Up @@ -66,7 +65,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
}
}

private def notExpireUsedRecords[F[_] : Concurrent : Timer : Par] = {
private def notExpireUsedRecords[F[_] : Concurrent : Timer : Parallel] = {
ExpiringCache.of[F, Int, Int](50.millis).use { cache =>
val touch = for {
_ <- Timer[F].sleep(10.millis)
Expand All @@ -88,7 +87,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
}


private def notExceedMaxSize[F[_] : Concurrent : Timer : Par] = {
private def notExceedMaxSize[F[_] : Concurrent : Timer : Parallel] = {
ExpiringCache.of[F, Int, Int](expireAfter = 100.millis, maxSize = 10.some).use { cache =>

def retryUntilCleaned(key: Int) = {
Expand All @@ -114,7 +113,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
}
}

private def refreshPeriodically[F[_] : Concurrent : Timer : Par] = {
private def refreshPeriodically[F[_] : Concurrent : Timer : Parallel] = {

val value = (key: Int) => key.pure[F]
val refresh = ExpiringCache.Refresh(100.millis, value)
Expand Down Expand Up @@ -143,7 +142,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
}
}

private def refreshDoesNotTouch[F[_] : Concurrent : Timer : Par] = {
private def refreshDoesNotTouch[F[_] : Concurrent : Timer : Parallel] = {
val value = (key: Int) => key.pure[F]
val refresh = ExpiringCache.Refresh(100.millis, value)

Expand Down Expand Up @@ -184,7 +183,7 @@ class ExpiringCacheSpec extends AsyncFunSuite with Matchers {
}
}

private def refreshFails[F[_] : Concurrent : Timer : Par] = {
private def refreshFails[F[_] : Concurrent : Timer : Parallel] = {

def valueOf(ref: Ref[F, Int]) = {
(_: Int) => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/evolutiongaming/scache/IOSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object IOSuite {
implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(executor)
implicit val concurrentIO: Concurrent[IO] = IO.ioConcurrentEffect
implicit val timerIO: Timer[IO] = IO.timer(executor)
implicit val parallel: Parallel[IO, IO.Par] = IO.ioParallel
implicit val parallel: Parallel[IO] = IO.ioParallel
implicit val measureDuration: MeasureDuration[IO] = MeasureDuration.fromClock(Clock[IO])

def runIO[A](io: IO[A], timeout: FiniteDuration = Timeout): Future[Succeeded.type] = {
Expand Down

0 comments on commit 0b4400c

Please sign in to comment.