Search code examples
javaspring-mvcmemcachedspymemcachedsimple-spring-memcached

Spring MemCached flush all strange behaviour


In a spring web project, if we are using a single cache server and different cache managers an eg annotation is

@Cacheable(value = "configCache", key="#key")
@Cacheable(value = "envCache", key="#key")
...

and if we do

@CacheEvict(value = "configCache", allEntries=true) 

and if we have enabled allowClear=true in the configuration, so will this only evict the configCache? or it will clear envCache as well?

We have seen many flush_all commands being executed in Amazon ElasticCache and majority of the items gets reclaimed. So is this because we are using evict allEntries?


Solution

  • If will also clear envCache if it's on the same memcached instance/server as configCache. Because memcached doesn't support namespaces only all keys can be removed from the instance.