Skip to content

Commit f5cb18b

Browse files
committed
make cachefactory methods static
1 parent e4d7603 commit f5cb18b

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Diff for: src/main/java/redis/clients/jedis/JedisCluster.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private JedisCluster(ClusterConnectionProvider provider, int maxAttempts, Durati
223223

224224
@Experimental
225225
public JedisCluster(Set<HostAndPort> hnp, JedisClientConfig jedisClientConfig, CacheConfig cacheConfig) {
226-
this(hnp, jedisClientConfig, new CacheFactory().getCache(cacheConfig));
226+
this(hnp, jedisClientConfig, CacheFactory.getCache(cacheConfig));
227227
}
228228

229229
@Experimental

Diff for: src/main/java/redis/clients/jedis/JedisPooled.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig client
8181

8282
@Experimental
8383
public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig clientConfig, CacheConfig cacheConfig) {
84-
this(hostAndPort, clientConfig, new CacheFactory().getCache(cacheConfig));
84+
this(hostAndPort, clientConfig, CacheFactory.getCache(cacheConfig));
8585
}
8686

8787
@Experimental
@@ -392,7 +392,7 @@ public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig client
392392
@Experimental
393393
public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig clientConfig, CacheConfig cacheConfig,
394394
final GenericObjectPoolConfig<Connection> poolConfig) {
395-
this(hostAndPort, clientConfig, new CacheFactory().getCache(cacheConfig), poolConfig);
395+
this(hostAndPort, clientConfig, CacheFactory.getCache(cacheConfig), poolConfig);
396396
}
397397

398398
@Experimental

Diff for: src/main/java/redis/clients/jedis/JedisSentineled.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public JedisSentineled(String masterName, final JedisClientConfig masterClientCo
1919
@Experimental
2020
public JedisSentineled(String masterName, final JedisClientConfig masterClientConfig, CacheConfig cacheConfig,
2121
Set<HostAndPort> sentinels, final JedisClientConfig sentinelClientConfig) {
22-
this(masterName, masterClientConfig, new CacheFactory().getCache(cacheConfig),
22+
this(masterName, masterClientConfig, CacheFactory.getCache(cacheConfig),
2323
sentinels, sentinelClientConfig);
2424
}
2525

Diff for: src/main/java/redis/clients/jedis/UnifiedJedis.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig) {
100100

101101
@Experimental
102102
public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig, CacheConfig cacheConfig) {
103-
this(hostAndPort, clientConfig, new CacheFactory().getCache(cacheConfig));
103+
this(hostAndPort, clientConfig, CacheFactory.getCache(cacheConfig));
104104
}
105105

106106
@Experimental

Diff for: src/main/java/redis/clients/jedis/csc/CacheFactory.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
import redis.clients.jedis.exceptions.JedisCacheException;
88

9-
public class CacheFactory {
9+
public final class CacheFactory {
1010

11-
public Cache getCache(CacheConfig config) {
11+
public static Cache getCache(CacheConfig config) {
1212
if (config.getCacheClass() == null) {
1313
return new DefaultCache(config.getMaxSize(), config.getCacheable(), getEvictionPolicy(config));
1414
}
1515
return instantiateCustomCache(config);
1616
}
1717

18-
private Cache instantiateCustomCache(CacheConfig config) {
18+
private static Cache instantiateCustomCache(CacheConfig config) {
1919
try {
2020
Constructor ctorWithCacheable = findConstructorWithCacheable(config.getCacheClass());
2121
if (ctorWithCacheable != null) {
@@ -28,14 +28,14 @@ private Cache instantiateCustomCache(CacheConfig config) {
2828
}
2929
}
3030

31-
private Constructor findConstructorWithCacheable(Class customCacheType) {
31+
private static Constructor findConstructorWithCacheable(Class customCacheType) {
3232
return Arrays.stream(customCacheType.getConstructors())
3333
.filter(
3434
ctor -> Arrays.equals(ctor.getParameterTypes(), new Class[] { int.class, EvictionPolicy.class, Cacheable.class }))
3535
.findFirst().orElse(null);
3636
}
3737

38-
private Constructor getConstructor(Class customCacheType) {
38+
private static Constructor getConstructor(Class customCacheType) {
3939
try {
4040
return customCacheType.getConstructor(int.class, EvictionPolicy.class);
4141
} catch (NoSuchMethodException e) {
@@ -48,7 +48,7 @@ private Constructor getConstructor(Class customCacheType) {
4848
}
4949
}
5050

51-
private EvictionPolicy getEvictionPolicy(CacheConfig config) {
51+
private static EvictionPolicy getEvictionPolicy(CacheConfig config) {
5252
if (config.getEvictionPolicy() == null) {
5353
// It will be default to LRUEviction, until we have other eviction implementations
5454
return new LRUEviction(config.getMaxSize());

0 commit comments

Comments
 (0)