Several caches in memcached

I transfer caches from EhCache to Memcached . Is there only one Memcached instance, is there a way to have multiple caches (like in EhCache)?

For example, I want to have a "Users" cache, a "Products" cache, etc. The main reason is that it can control and configure each cache separately and be able to clear them separately too.

+5
source share
1 answer

Typically, this kind of behavior is achieved in memcached through a namespace. Within one memcached instance, multiple namespaces are supported, each of which represents a different cache. However, memcached does not support namespace names; instead, memcached namespaces are emulated using prefix keys with a namespace identifier (for example, memcachedClient.get('products.top10')). Some memcached clients, such as the Python GAE memcached client , render this behavior for you. However, as far as I can tell, xmemcached does not.

There are two options left.

  • Manually add each key you are working with.
  • XMemcachedClient : String namespace, , get0(), . , XMemcached.
+4

All Articles