views:

25

answers:

1

(I may be totally off in my understanding here but I still would like to ask.)

The MemcacheServiceFactory can return a MemcacheService instance given a namespace.

Can one application request MemcacheService instances for more than one namespace? If yes, can namespace be used as a grouping concept?

For instance, say my model has folders and files and I use folder names as namespaces. I can store cached data for files that belong to a certain folder in the MemcacheService instance with that folder's name as the namespace. And when I delete the folder I simply clear all entries in this MemcacheService instance there by not affecting any other folders or files.

Thanks, Keyur

+1  A: 

Yes, you can get service implementations for any number of namespaces within the same application. Namespaces are intended to provide separation between different concerns using the memcache service from within the same app, to eliminate the need to mangle your keys to avoid collisions.

The approach you describe won't work because there's no way to get a list of all keys in a namespace, nor is there a way to clear all keys in one specific namespace (only the whole of memcache).

Nick Johnson
Thanks, Nick. I was under the impression that clearAll() would clear keys only in one specific namespace. But as you mention and as the javadoc confirms, that isn't the case.
Keyur