14
14
import redis .clients .jedis .util .SafeEncoder ;
15
15
16
16
/**
17
- * The class to manage the client-side caching. User can provide any of implementation of this class
18
- * to the client object; e.g. {@link redis.clients.jedis.csc.CaffeineClientSideCache
19
- * CaffeineClientSideCache} or {@link redis.clients.jedis.csc.GuavaClientSideCache
20
- * GuavaClientSideCache} or a custom implementation of their own.
17
+ * The class to manage the client-side caching. User can provide an of implementation of this class
18
+ * to the client object.
21
19
*/
22
20
@ Experimental
23
21
public abstract class AbstractCache implements Cache {
24
22
25
- private ClientSideCacheable cacheable ;
23
+ private Cacheable cacheable ;
26
24
private final Map <ByteBuffer , Set <CacheKey <?>>> redisKeysToCacheKeys = new ConcurrentHashMap <>();
27
25
private final int maximumSize ;
28
26
private ReentrantLock lock = new ReentrantLock ();
29
27
private volatile CacheStats stats = new CacheStats ();
30
28
31
29
protected AbstractCache (int maximumSize ) {
32
- this (maximumSize , DefaultClientSideCacheable .INSTANCE );
30
+ this (maximumSize , DefaultCacheable .INSTANCE );
33
31
}
34
32
35
- protected AbstractCache (int maximumSize , ClientSideCacheable cacheable ) {
33
+ protected AbstractCache (int maximumSize , Cacheable cacheable ) {
36
34
this .maximumSize = maximumSize ;
37
35
this .cacheable = cacheable ;
38
36
}
@@ -89,7 +87,7 @@ public CacheEntry set(CacheKey cacheKey, CacheEntry entry) {
89
87
}
90
88
91
89
@ Override
92
- public Boolean delete (CacheKey cacheKey ) {
90
+ public boolean delete (CacheKey cacheKey ) {
93
91
lock .lock ();
94
92
try {
95
93
boolean removed = removeFromStore (cacheKey );
@@ -171,12 +169,12 @@ public int flush() {
171
169
}
172
170
173
171
@ Override
174
- public Boolean isCacheable (CacheKey cacheKey ) {
175
- return cacheable .isCacheable (cacheKey .getCommand (). getArguments (). getCommand (), cacheKey .getRedisKeys ());
172
+ public boolean isCacheable (CacheKey cacheKey ) {
173
+ return cacheable .isCacheable (cacheKey .getRedisCommand (), cacheKey .getRedisKeys ());
176
174
}
177
175
178
176
@ Override
179
- public Boolean hasCacheKey (CacheKey cacheKey ) {
177
+ public boolean hasCacheKey (CacheKey cacheKey ) {
180
178
return containsKeyInStore (cacheKey );
181
179
}
182
180
@@ -202,13 +200,13 @@ public CacheStats getAndResetStats() {
202
200
203
201
protected abstract CacheEntry putIntoStore (CacheKey cacheKey , CacheEntry entry );
204
202
205
- protected abstract Boolean removeFromStore (CacheKey cacheKey );
203
+ protected abstract boolean removeFromStore (CacheKey cacheKey );
206
204
207
205
// protected abstract Collection<CacheKey> remove(Set<CacheKey<?>> commands);
208
206
209
207
protected abstract void clearStore ();
210
208
211
- protected abstract Boolean containsKeyInStore (CacheKey cacheKey );
209
+ protected abstract boolean containsKeyInStore (CacheKey cacheKey );
212
210
213
211
// End of abstract methods to be implemented by the concrete classes
214
212
0 commit comments