Class ScoredRedisCacheWriter
- java.lang.Object
-
- org.oxerr.spring.cache.redis.scored.ScoredRedisCacheWriter
-
- All Implemented Interfaces:
org.springframework.data.redis.cache.CacheStatisticsProvider
,org.springframework.data.redis.cache.RedisCacheWriter
public class ScoredRedisCacheWriter extends Object implements org.springframework.data.redis.cache.RedisCacheWriter
RedisCacheWriter
implementation using sorted set as back-end store.
-
-
Field Summary
Fields Modifier and Type Field Description private org.springframework.data.redis.cache.RedisCacheWriter
cacheWriter
private org.springframework.data.redis.connection.RedisConnectionFactory
connectionFactory
private static Double
DEFAULT_SCORE
private static String
KEY_NOT_NULL
private static String
MUST_NOT_BE_NULL
private static String
NAME_NOT_NULL
private static String
OK
private ScoreHolder
scoreHolder
private org.springframework.data.redis.cache.CacheStatisticsCollector
statistics
private static String
VALUE_NOT_NULL
-
Constructor Summary
Constructors Constructor Description ScoredRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
ScoredRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
ScoredRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector, ScoreHolder scoreHolder)
ScoredRedisCacheWriter(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector, ScoreHolder scoreHolder, org.springframework.data.redis.cache.RedisCacheWriter cacheWriter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clean(String name, byte[] pattern)
void
clearStatistics(String name)
private <T> T
execute(String name, Function<org.springframework.data.redis.connection.RedisConnection,T> callback)
byte[]
get(String name, byte[] key)
org.springframework.data.redis.cache.CacheStatistics
getCacheStatistics(String cacheName)
private double
getScore()
void
put(String name, byte[] key, byte[] value, Duration ttl)
byte[]
putIfAbsent(String name, byte[] key, byte[] value, Duration ttl)
void
remove(String name, byte[] key)
private static boolean
shouldExpireWithin(Duration ttl)
ScoredRedisCacheWriter
withStatisticsCollector(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
-
-
-
Field Detail
-
MUST_NOT_BE_NULL
private static final String MUST_NOT_BE_NULL
- See Also:
- Constant Field Values
-
NAME_NOT_NULL
private static final String NAME_NOT_NULL
- See Also:
- Constant Field Values
-
KEY_NOT_NULL
private static final String KEY_NOT_NULL
- See Also:
- Constant Field Values
-
VALUE_NOT_NULL
private static final String VALUE_NOT_NULL
- See Also:
- Constant Field Values
-
OK
private static final String OK
- See Also:
- Constant Field Values
-
DEFAULT_SCORE
private static final Double DEFAULT_SCORE
-
connectionFactory
private final org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory
-
statistics
private final org.springframework.data.redis.cache.CacheStatisticsCollector statistics
-
scoreHolder
private final ScoreHolder scoreHolder
-
cacheWriter
private final org.springframework.data.redis.cache.RedisCacheWriter cacheWriter
-
-
Constructor Detail
-
ScoredRedisCacheWriter
public ScoredRedisCacheWriter(@NonNull org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
-
ScoredRedisCacheWriter
public ScoredRedisCacheWriter(@NonNull org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, @NonNull org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
-
ScoredRedisCacheWriter
public ScoredRedisCacheWriter(@NonNull org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, @NonNull org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector, @NonNull ScoreHolder scoreHolder)
-
ScoredRedisCacheWriter
public ScoredRedisCacheWriter(@NonNull org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, @NonNull org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector, @NonNull ScoreHolder scoreHolder, @NonNull org.springframework.data.redis.cache.RedisCacheWriter cacheWriter)
-
-
Method Detail
-
getCacheStatistics
public org.springframework.data.redis.cache.CacheStatistics getCacheStatistics(String cacheName)
- Specified by:
getCacheStatistics
in interfaceorg.springframework.data.redis.cache.CacheStatisticsProvider
-
put
public void put(String name, byte[] key, byte[] value, Duration ttl)
- Specified by:
put
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
get
public byte[] get(String name, byte[] key)
- Specified by:
get
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
putIfAbsent
public byte[] putIfAbsent(String name, byte[] key, byte[] value, Duration ttl)
- Specified by:
putIfAbsent
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
remove
public void remove(String name, byte[] key)
- Specified by:
remove
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
clean
public void clean(String name, byte[] pattern)
- Specified by:
clean
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
clearStatistics
public void clearStatistics(String name)
- Specified by:
clearStatistics
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
withStatisticsCollector
public ScoredRedisCacheWriter withStatisticsCollector(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
- Specified by:
withStatisticsCollector
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
execute
private <T> T execute(String name, Function<org.springframework.data.redis.connection.RedisConnection,T> callback)
-
shouldExpireWithin
private static boolean shouldExpireWithin(@Nullable Duration ttl)
-
getScore
private double getScore()
-
-