How to create RedisCacheManager in spring-data 3.0.x

219 Views Asked by At

I'm migrating my application from spring boot 1.5.x to 3.0.x. I want to keep jedis but I have a problem with the instantiation of RedisCacheManager.

Now constructor signature is

RedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration)

But before it was:

RedisCacheManager(RedisOperations redisOperations)

I define this bean having only RedisTemplate in scope:

@Bean
    public CacheManager cacheManager1(RedisTemplate redisTemplate) {
        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
        cacheManager.setDefaultExpiration(300);
        HashMap<String, Long> expires = new HashMap<>();
        expires.put("DELIVERED_DLR_MESSAGE_PART_COUNT_MAP", new Long(1000));
        expires.put("FAILED_DLR_MESSAGE_PART_COUNT_MAP", new Long(1000));
        cacheManager.setExpires(expires);
        cacheManager.setUsePrefix(true);

        return cacheManager;
    }

How is it supposed to be created now?

0

There are 0 best solutions below