Click here to Skip to main content
15,888,202 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ll
I am using redis cache on my local Machine. I have enabled the cache for one of my method using the cacheable anothion. Application is not able to cache my method.

public class RedisConfig {

    @Autowired
    private JedisConnectionFactory jedisConnectionFactory;

    @Bean
    public RedisTemplate<Object, Object> redisTemplate() {

        System.out.println("localhost")
        System.out.println("6379");
        jedisConnectionFactory.getHostName();
        jedisConnectionFactory.getPort();

        RedisTemplate<Object, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(jedisConnectionFactory);
        template.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));
        return template;
    }

    @Bean
    public CacheManager cacheManager(RedisTemplate redisTemplate) {
        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
        // Number of seconds before expiration. Defaults to unlimited (0)
        cacheManager.setDefaultExpiration(60);
        cacheManager.setUsePrefix(true);
        return cacheManager;
    }

}
@Cacheable(value="sgcode" , cacheManager ="cacheManager")
    public String getSegmentCode(String aname ) {
        Logger.info("code ", "##### SEGMENT METHOD CALLED ##### {}", aname);
        return segmentCodeMap.get(aname);       
    }


What I have tried:

When i am trying to hit my application the application is not able to cache my method.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900