App Engine - MemcacheService Namespaces

(I may not be completely understanding, but I would still like to ask.)

MemcacheServiceFactory can return an instance of MemcacheService by specifying a namespace.

Can a single application request instances of MemcacheService for multiple namespaces? If so, can the namespace be used as a concept of grouping?

For example, let's say my model has folders and files, and I use folder names as namespaces. I can store cached data for files belonging to a specific folder in a MemcacheService instance with the name of this folder as a namespace. And when I delete the folder, I just delete all the entries in this MemcacheService instance without affecting any other folders or files.

Thanks Keyur

+3
source share
1 answer

Yes, you can get service implementations for any number of namespaces in one application. Namespaces are designed to provide a separation between different problems using memcache from the same application to eliminate the need to lock your keys to avoid collisions.

The approach you describe will not work, because there is no way to get a list of all the keys in the namespace, and there is no way to delete all the keys in one specific namespace (only the entire memcache).

+6
source

Source: https://habr.com/ru/post/1752560/


All Articles