javamemcachedspring-annotationssimple-spring-memcached

Invalidate entire namespace using Simple Spring Memcached


Has anyone tried invalidating an entire memcached namespace?

For example I have two reads methods having differents keys

@Override
@ReadThroughSingleCache(namespace = UrlClientExclusion.TABLE_NAME, expiration = 24 * HOUR)
public List<UrlClientExclusion> list(@ParameterValueKeyProvider String idClient) {

@Override
@ReadThroughSingleCache(namespace = UrlClientExclusion.TABLE_NAME, expiration = 24 * HOUR)
public UrlClientExclusion find(@ParameterValueKeyProvider int idUrlClientExclusion) {

and I want delete entire namespace UrlClientExclusion.TABLE_NAME on update/delete operation

I can't use a keylist method because there are many instances of the app

@InvalidateMultiCache(namespace = UrlClientExclusion.TABLE_NAME)
public int update(UrlClientExclusion urlClientExclusion, /*@ParameterValueKeyProvider List<Object> keylist*/ /* it is impossibile for me put all keys in this list*/) {

so the solution is to delete entire namespace.

What is the annototation to do this? It is possibible to build custom annotation to delete entire namespace? How?

Many thanks


Solution

  • Memcached doesn't support namespaces, SSM provides namespaces as a logic abstraction. It is not possible to flush all keys from given namespaces as memcached doesn't group keys into namespaces. Memcached support only flushing/removing single key or all keys.

    You can flush all your data from memcached instance or need to provide exact keys that should be removed.