Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing imports and class naming #17

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading