From 6a9b5d59a4c73298eb63a09a52c0b66d634126f2 Mon Sep 17 00:00:00 2001 From: Ben Plommer Date: Tue, 7 Sep 2021 10:42:13 +0100 Subject: [PATCH] Remove redundand context bound --- .../main/scala/scalacache/redis/RedisCache.scala | 11 +++++------ .../scala/scalacache/redis/RedisCacheBase.scala | 2 +- .../scala/scalacache/redis/SentinelRedisCache.scala | 13 ++++++------- .../scala/scalacache/redis/ShardedRedisCache.scala | 11 +++++------ 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/modules/redis/src/main/scala/scalacache/redis/RedisCache.scala b/modules/redis/src/main/scala/scalacache/redis/RedisCache.scala index be784c9a..358d7940 100644 --- a/modules/redis/src/main/scala/scalacache/redis/RedisCache.scala +++ b/modules/redis/src/main/scala/scalacache/redis/RedisCache.scala @@ -5,17 +5,16 @@ import redis.clients.jedis._ import scala.language.higherKinds import scalacache.CacheConfig import scalacache.serialization.Codec -import cats.effect.{MonadCancel, MonadCancelThrow, Resource, Sync} +import cats.effect.{MonadCancel, Resource, Sync} /** Thin wrapper around Jedis */ -class RedisCache[F[_]: Sync: MonadCancelThrow, V](val jedisPool: JedisPool)(implicit +class RedisCache[F[_]: Sync, V](val jedisPool: JedisPool)(implicit val config: CacheConfig, val codec: Codec[V] ) extends RedisCacheBase[F, V] { - protected def F: Sync[F] = Sync[F] - protected def MonadCancelThrowF: MonadCancelThrow[F] = MonadCancel[F, Throwable] + protected def F: Sync[F] = Sync[F] type JClient = Jedis protected val doRemoveAll: F[Unit] = withJedis { jedis => @@ -27,7 +26,7 @@ object RedisCache { /** Create a Redis client connecting to the given host and use it for caching */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( host: String, port: Int )(implicit config: CacheConfig, codec: Codec[V]): RedisCache[F, V] = @@ -37,7 +36,7 @@ object RedisCache { * @param jedisPool * a Jedis pool */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( jedisPool: JedisPool )(implicit config: CacheConfig, codec: Codec[V]): RedisCache[F, V] = new RedisCache[F, V](jedisPool) diff --git a/modules/redis/src/main/scala/scalacache/redis/RedisCacheBase.scala b/modules/redis/src/main/scala/scalacache/redis/RedisCacheBase.scala index 5e3500b2..9a724e6d 100644 --- a/modules/redis/src/main/scala/scalacache/redis/RedisCacheBase.scala +++ b/modules/redis/src/main/scala/scalacache/redis/RedisCacheBase.scala @@ -9,7 +9,7 @@ import scalacache.serialization.Codec import scalacache.{AbstractCache, CacheConfig} import scala.concurrent.duration._ -import cats.effect.{MonadCancelThrow, Resource} +import cats.effect.Resource import cats.syntax.all._ /** Contains implementations of all methods that can be implemented independent of the type of Redis client. This is diff --git a/modules/redis/src/main/scala/scalacache/redis/SentinelRedisCache.scala b/modules/redis/src/main/scala/scalacache/redis/SentinelRedisCache.scala index a0f1e667..a03a8487 100644 --- a/modules/redis/src/main/scala/scalacache/redis/SentinelRedisCache.scala +++ b/modules/redis/src/main/scala/scalacache/redis/SentinelRedisCache.scala @@ -7,17 +7,16 @@ import scala.collection.JavaConverters._ import scalacache.CacheConfig import scalacache.serialization.Codec import cats.implicits._ -import cats.effect.{MonadCancel, MonadCancelThrow, Sync} +import cats.effect.{MonadCancel, Sync} /** Thin wrapper around Jedis that works with Redis Sentinel. */ -class SentinelRedisCache[F[_]: Sync: MonadCancelThrow, V](val jedisPool: JedisSentinelPool)(implicit +class SentinelRedisCache[F[_]: Sync, V](val jedisPool: JedisSentinelPool)(implicit val config: CacheConfig, val codec: Codec[V] ) extends RedisCacheBase[F, V] { - protected def F: Sync[F] = Sync[F] - protected def MonadCancelThrowF: MonadCancelThrow[F] = MonadCancel[F, Throwable] + protected def F: Sync[F] = Sync[F] type JClient = Jedis @@ -39,7 +38,7 @@ object SentinelRedisCache { * @param password * password of the cluster */ - def apply[F[_]: Sync: MonadCancelThrow, V](clusterName: String, sentinels: Set[String], password: String)(implicit + def apply[F[_]: Sync, V](clusterName: String, sentinels: Set[String], password: String)(implicit config: CacheConfig, codec: Codec[V] ): SentinelRedisCache[F, V] = @@ -56,7 +55,7 @@ object SentinelRedisCache { * @param poolConfig * config of the underlying pool */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( clusterName: String, sentinels: Set[String], poolConfig: GenericObjectPoolConfig, @@ -72,7 +71,7 @@ object SentinelRedisCache { * @param jedisSentinelPool * a JedisSentinelPool */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( jedisSentinelPool: JedisSentinelPool )(implicit config: CacheConfig, codec: Codec[V]): SentinelRedisCache[F, V] = new SentinelRedisCache[F, V](jedisSentinelPool) diff --git a/modules/redis/src/main/scala/scalacache/redis/ShardedRedisCache.scala b/modules/redis/src/main/scala/scalacache/redis/ShardedRedisCache.scala index b639f7b5..3fc2ef84 100644 --- a/modules/redis/src/main/scala/scalacache/redis/ShardedRedisCache.scala +++ b/modules/redis/src/main/scala/scalacache/redis/ShardedRedisCache.scala @@ -6,17 +6,16 @@ import scala.collection.JavaConverters._ import scala.language.higherKinds import scalacache.CacheConfig import scalacache.serialization.Codec -import cats.effect.{MonadCancel, MonadCancelThrow, Sync} +import cats.effect.{MonadCancel, Sync} /** Thin wrapper around Jedis that works with sharded Redis. */ -class ShardedRedisCache[F[_]: Sync: MonadCancelThrow, V](val jedisPool: ShardedJedisPool)(implicit +class ShardedRedisCache[F[_]: Sync, V](val jedisPool: ShardedJedisPool)(implicit val config: CacheConfig, val codec: Codec[V] ) extends RedisCacheBase[F, V] { - protected def F: Sync[F] = Sync[F] - protected def MonadCancelThrowF: MonadCancelThrow[F] = MonadCancel[F, Throwable] + protected def F: Sync[F] = Sync[F] type JClient = ShardedJedis @@ -32,7 +31,7 @@ object ShardedRedisCache { /** Create a sharded Redis client connecting to the given hosts and use it for caching */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( hosts: (String, Int)* )(implicit config: CacheConfig, codec: Codec[V]): ShardedRedisCache[F, V] = { val shards = hosts.map { case (host, port) => @@ -46,7 +45,7 @@ object ShardedRedisCache { * @param jedisPool * a ShardedJedis pool */ - def apply[F[_]: Sync: MonadCancelThrow, V]( + def apply[F[_]: Sync, V]( jedisPool: ShardedJedisPool )(implicit config: CacheConfig, codec: Codec[V]): ShardedRedisCache[F, V] = new ShardedRedisCache[F, V](jedisPool)