Class 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 Detail

      • 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
      • 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 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()