title: Why Redis Cache is not getting empty in my Spring Boot application?
body: <p>I am using Redis Cache in my Spring Boot application to store data of multiple rest API's. </p>
  
  <p>I am clearing Redis cache on a regular interval using Spring Cron Jobs. The method is getting called at required time-slots. </p>
  
  <p>I have verified the logs but the cache is not getting clear and hence it is showing the stale data. </p>
  
  <p>The code where I'm trying to clear the cache.</p>
  
  <pre><code>public class CustomerDerivation {
      @Autowired
      @Qualifier("redisCacheMngr")
      CacheManager redisCacheMngr;
  
      @Scheduled(cron = "${redis.api.update.interval}")
      @CacheEvict(value = "redis-cache", allEntries = true, cacheNames = {"redis-cache"})
      protected void cacheEvict() {
          redisCacheMngr.getCache("redis-cache").clear();
          logger.info("Evicting ModelCache");
      }
  }
  </code></pre>
  
  <p>Custom cache configuration code. </p>
  
  <pre><code>@Configuration
  @Profile("cloud")
  public class CacheConfig extends AbstractCloudConfig {
      @Autowired
      Environment env;
  
      @Bean
      public RedisConnectionFactory brRedisFactory() {
          return connectionFactory().redisConnectionFactory(env.getProperty("model_cache_name"));
      }
  
      @Bean
      public RedisTemplate&lt;String, Object&gt; brRedisTemplate() {
          RedisTemplate&lt;String, Object&gt; redisTemplate = new RedisTemplate&lt;String, Object&gt;();
          redisTemplate.setConnectionFactory(brRedisFactory());
          return redisTemplate;
      }
  
      @Bean(name = "redisCacheMngr")
      public CacheManager cacheManager() {
          RedisCacheManager cacheManager = new RedisCacheManager(brRedisTemplate());
          cacheManager.setUsePrefix(true);
          cacheManager.setTransactionAware(true);
          return cacheManager;
      }
  }
  </code></pre>
  
  <p>How to fix the code to clear the redis cache ?</p>