Click here to Skip to main content
15,665,942 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 {

    private JedisConnectionFactory jedisConnectionFactory;

    public RedisTemplate<Object, Object> redisTemplate() {


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

    public CacheManager cacheManager(RedisTemplate redisTemplate) {
        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
        // Number of seconds before expiration. Defaults to unlimited (0)
        return cacheManager;

@Cacheable(value="sgcode" , cacheManager ="cacheManager")
    public String getSegmentCode(String aname ) {"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.

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