Skip to content

Commit

Permalink
Merge pull request #578 from bplommer/remove-monadcancelthrow
Browse files Browse the repository at this point in the history
Remove redundant context bound (Sync already implies MonadCancelThrow)
  • Loading branch information
kubukoz authored Sep 13, 2021
2 parents 401a0b6 + 6a9b5d5 commit d11636d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
11 changes: 5 additions & 6 deletions modules/redis/src/main/scala/scalacache/redis/RedisCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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] =
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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] =
Expand All @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) =>
Expand All @@ -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)
Expand Down

0 comments on commit d11636d

Please sign in to comment.