Skip to content

Commit

Permalink
Merge pull request #17 from scoquelin/quick-follow-up-on-cached-clients
Browse files Browse the repository at this point in the history
Fixing imports and class naming
  • Loading branch information
scoquelin authored Jul 30, 2024
2 parents 9c085a5 + c1061ba commit dfce05d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ trait BaseRedisCommandsIntegrationSpec extends AsyncWordSpecLike with TestContai
clientResources = clientResources
)

cachedClients = RedisCommandCachedClients(redisSingleNodeConfig, redisClusterConfig)
cachedClients = RedisCommandsCachedClients(redisSingleNodeConfig, redisClusterConfig)
}

override def afterEach(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.scoquelin.arugula

import com.github.scoquelin.arugula.codec.RedisCodec
import com.github.scoquelin.arugula.codec.LongCodec
import com.github.scoquelin.arugula.codec.{LongCodec, RedisCodec}
import com.github.scoquelin.arugula.config.LettuceRedisClientConfig
import io.lettuce.core.codec.{StringCodec => JStringCodec, RedisCodec => JRedisCodec}
import io.lettuce.core.codec.{StringCodec => JStringCodec}

import scala.concurrent.ExecutionContext

Expand All @@ -17,12 +16,12 @@ trait CachedClients {
def getClient[K, V](codec: RedisCodec[K, V], connectionType: RedisConnectionType): RedisCommandsClient[K, V]
}

private class RedisCommandCachedClients(redisSingleNodeClientWithStringValue: RedisCommandsClient[String, String],
redisSingleNodeClientWithLongValue: RedisCommandsClient[String, Long],
redisClusterClientWithStringValue: RedisCommandsClient[String, String],
redisClusterClientWithLongValue: RedisCommandsClient[String, Long]) extends CachedClients {
private class RedisCommandsCachedClients(redisSingleNodeClientWithStringValue: RedisCommandsClient[String, String],
redisSingleNodeClientWithLongValue: RedisCommandsClient[String, Long],
redisClusterClientWithStringValue: RedisCommandsClient[String, String],
redisClusterClientWithLongValue: RedisCommandsClient[String, Long]) extends CachedClients {

def getClient[K, V](codec: RedisCodec[K, V], connectionType: RedisConnectionType): RedisCommandsClient[K, V] = {
override def getClient[K, V](codec: RedisCodec[K, V], connectionType: RedisConnectionType): RedisCommandsClient[K, V] = {
(codec, connectionType) match {
case (RedisCodec(JStringCodec.UTF8), SingleNode) => redisSingleNodeClientWithStringValue.asInstanceOf[RedisCommandsClient[K, V]]
case (RedisCodec(JStringCodec.UTF8), Cluster) => redisClusterClientWithStringValue.asInstanceOf[RedisCommandsClient[K, V]]
Expand All @@ -33,13 +32,13 @@ private class RedisCommandCachedClients(redisSingleNodeClientWithStringValue: Re
}
}

object RedisCommandCachedClients {
object RedisCommandsCachedClients {
def apply(singleNodeConfig: LettuceRedisClientConfig, clusterConfig: LettuceRedisClientConfig)(implicit ec: ExecutionContext): CachedClients = {
val redisSingleNodeClientWithStringValue = LettuceRedisCommandsClient(singleNodeConfig, RedisCodec.Utf8WithValueAsStringCodec)
val redisSingleNodeClientWithLongValue = LettuceRedisCommandsClient(singleNodeConfig, RedisCodec.Utf8WithValueAsLongCodec)
val redisClusterClientWithStringValue = LettuceRedisCommandsClient(clusterConfig, RedisCodec.Utf8WithValueAsStringCodec)
val redisClusterClientWithLongValue = LettuceRedisCommandsClient(clusterConfig, RedisCodec.Utf8WithValueAsLongCodec)
new RedisCommandCachedClients(
new RedisCommandsCachedClients(
redisSingleNodeClientWithStringValue,
redisSingleNodeClientWithLongValue,
redisClusterClientWithStringValue,
Expand Down

0 comments on commit dfce05d

Please sign in to comment.