How to flush all the cache entries in simple spring memcached

1.7k views Asked by At

This question is with reference to Simple Spring memcached.

I have a scenario where a list of deals are cached for user using the userId as the key. Now in case a deal data is updated I need to flush the cache for all users since this would affect deals data for all the users. How can I achieve this with SSM annotations. The invalidate*cache and update*cache options seem to invalidate/update key specific cache entries whereas I need to clear the entire cache.

1

There are 1 answers

0
ragnor On

Currently it's impossible in plain SSM to flush entire cache using annotations, if you require such option please create a feature request on: https://code.google.com/p/simple-spring-memcached/issues/list

There is another way to flush entire cache by using SSM with Spring Cache as describer here: https://code.google.com/p/simple-spring-memcached/wiki/Getting_Started#Spring_3.1_Cache_Integration. Just change allowClear to 'true' and use @CacheEvict(value = YOUR_CACHE_NAME, allEntries = true)