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 Details

    • MUST_NOT_BE_NULL

      private static final String MUST_NOT_BE_NULL
      See Also:
    • NAME_NOT_NULL

      private static final String NAME_NOT_NULL
      See Also:
    • KEY_NOT_NULL

      private static final String KEY_NOT_NULL
      See Also:
    • VALUE_NOT_NULL

      private static final String VALUE_NOT_NULL
      See Also:
    • OK

      private static final String OK
      See Also:
    • 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 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

      public org.springframework.data.redis.cache.CacheStatistics getCacheStatistics(String cacheName)
      Specified by:
      getCacheStatistics in interface org.springframework.data.redis.cache.CacheStatisticsProvider
    • put

      public void put(String name, byte[] key, byte[] value, Duration ttl)
      Specified by:
      put in interface org.springframework.data.redis.cache.RedisCacheWriter
    • get

      public byte[] get(String name, byte[] key)
      Specified by:
      get in interface org.springframework.data.redis.cache.RedisCacheWriter
    • putIfAbsent

      public byte[] putIfAbsent(String name, byte[] key, byte[] value, Duration ttl)
      Specified by:
      putIfAbsent in interface org.springframework.data.redis.cache.RedisCacheWriter
    • remove

      public void remove(String name, byte[] key)
      Specified by:
      remove in interface org.springframework.data.redis.cache.RedisCacheWriter
    • clean

      public void clean(String name, byte[] pattern)
      Specified by:
      clean in interface org.springframework.data.redis.cache.RedisCacheWriter
    • clearStatistics

      public void clearStatistics(String name)
      Specified by:
      clearStatistics in interface org.springframework.data.redis.cache.RedisCacheWriter
    • withStatisticsCollector

      public ScoredRedisCacheWriter withStatisticsCollector(org.springframework.data.redis.cache.CacheStatisticsCollector cacheStatisticsCollector)
      Specified by:
      withStatisticsCollector in interface org.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()