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
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.data.redis.cache.RedisCacheWriter
private final org.springframework.data.redis.connection.RedisConnectionFactory
private static final Double
private static final String
private static final String
private static final String
private static final String
private final ScoreHolder
private final org.springframework.data.redis.cache.CacheStatisticsCollector
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionScoredRedisCacheWriter
(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
Modifier and TypeMethodDescriptionvoid
void
clearStatistics
(String name) private <T> T
execute
(String name, Function<org.springframework.data.redis.connection.RedisConnection, T> callback) byte[]
org.springframework.data.redis.cache.CacheStatistics
getCacheStatistics
(String cacheName) private double
getScore()
void
byte[]
putIfAbsent
(String name, byte[] key, byte[] value, Duration ttl) void
private static boolean
withStatisticsCollector
(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
-
Field Details
-
MUST_NOT_BE_NULL
- See Also:
-
NAME_NOT_NULL
- See Also:
-
KEY_NOT_NULL
- See Also:
-
VALUE_NOT_NULL
- See Also:
-
OK
- See Also:
-
DEFAULT_SCORE
-
connectionFactory
private final org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory -
statistics
private final org.springframework.data.redis.cache.CacheStatisticsCollector statistics -
scoreHolder
-
cacheWriter
private final org.springframework.data.redis.cache.RedisCacheWriter cacheWriter
-
-
Constructor Details
-
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 Details
-
getCacheStatistics
- Specified by:
getCacheStatistics
in interfaceorg.springframework.data.redis.cache.CacheStatisticsProvider
-
put
- Specified by:
put
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
get
- Specified by:
get
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
remove
- Specified by:
remove
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
clean
- Specified by:
clean
in interfaceorg.springframework.data.redis.cache.RedisCacheWriter
-
clearStatistics
- 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
-
shouldExpireWithin
-
getScore
private double getScore()
-