|
5 | 5 | import java.util.concurrent.TimeUnit;
|
6 | 6 |
|
7 | 7 | import redis.clients.jedis.csc.hash.CommandLongHasher;
|
8 |
| -import redis.clients.jedis.csc.hash.OpenHftCommandHasher; |
| 8 | +import redis.clients.jedis.csc.hash.SimpleCommandHasher; |
9 | 9 |
|
10 | 10 | public class CaffeineClientSideCache extends ClientSideCache {
|
11 | 11 |
|
12 | 12 | private final Cache<Long, Object> cache;
|
13 | 13 |
|
14 | 14 | public CaffeineClientSideCache(Cache<Long, Object> caffeineCache) {
|
15 |
| - this(caffeineCache, DefaultClientSideCacheable.INSTANCE); |
| 15 | + this(caffeineCache, SimpleCommandHasher.INSTANCE); |
| 16 | + } |
| 17 | + |
| 18 | + public CaffeineClientSideCache(Cache<Long, Object> caffeineCache, CommandLongHasher commandHasher) { |
| 19 | + this(caffeineCache, commandHasher, DefaultClientSideCacheable.INSTANCE); |
16 | 20 | }
|
17 | 21 |
|
18 | 22 | public CaffeineClientSideCache(Cache<Long, Object> caffeineCache, ClientSideCacheable cacheable) {
|
19 |
| - this(caffeineCache, new OpenHftCommandHasher(OpenHftCommandHasher.DEFAULT_HASH_FUNCTION), cacheable); |
| 23 | + this(caffeineCache, SimpleCommandHasher.INSTANCE, cacheable); |
20 | 24 | }
|
21 | 25 |
|
22 | 26 | public CaffeineClientSideCache(Cache<Long, Object> caffeineCache, CommandLongHasher commandHasher, ClientSideCacheable cacheable) {
|
@@ -55,7 +59,7 @@ public static class Builder {
|
55 | 59 | private final TimeUnit expireTimeUnit = TimeUnit.SECONDS;
|
56 | 60 |
|
57 | 61 | // not using a default value to avoid an object creation like 'new OpenHftHashing(hashFunction)'
|
58 |
| - private CommandLongHasher commandHasher = null; |
| 62 | + private CommandLongHasher commandHasher = SimpleCommandHasher.INSTANCE; |
59 | 63 |
|
60 | 64 | private ClientSideCacheable cacheable = DefaultClientSideCacheable.INSTANCE;
|
61 | 65 |
|
@@ -88,8 +92,7 @@ public CaffeineClientSideCache build() {
|
88 | 92 |
|
89 | 93 | cb.expireAfterWrite(expireTime, expireTimeUnit);
|
90 | 94 |
|
91 |
| - return commandHasher != null ? new CaffeineClientSideCache(cb.build(), commandHasher, cacheable) |
92 |
| - : new CaffeineClientSideCache(cb.build(), cacheable); |
| 95 | + return new CaffeineClientSideCache(cb.build(), commandHasher, cacheable); |
93 | 96 | }
|
94 | 97 | }
|
95 | 98 | }
|
0 commit comments