when setting up Django to use Memcached for caching (in my case, I want to to use session caching), in settings.py
we set
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
I will be running the project in App Engine so my question is what do I do to for the LOCATION
entry?
The location should be set as your ip and port where your memcache daemon is running.
Check this in django official documentation.
https://docs.djangoproject.com/en/dev/topics/cache/
If you are following this documentation http://www.allbuttonspressed.com/projects/djangoappengine
And cloning this (as asked in the above link) https://github.com/django-nonrel/djangoappengine/blob/master/djangoappengine/settings_base.py
I don't think you need to define a location. Is it throwing an error when you don't define it?
As it happens, I have been porting a Django (1.6.5) application to GAE over the last few days (GAE Development SDK 1.9.6). I don't have a big need for caching right now but it's good to know it's available if I need it.
So I just tried using
django.core.cache.backends.memcached.MemcachedCache
as my cache backend (set up as you describe in your question, and I put python-memcached in my libs folder) andto manage my sessions and GAE gave me the error:
Anyway...
...even if you could get this to work it's surely better to use Google's API lib and borrow from the Django Memcached implementation, especially as the Google lib has been designed to be compatible with python-memcached and otherwise your app could break at any time with an SDK update. Create a python module such as
my_project/backends.py
:Then your cache setting becomes:
That's it! This seems to work fine but I should be clear that it is not rigorously tested!
Aside
Have a poke around in
google.appengine.api.memcache.__init__.py
in your GAE SDK folder and you will find:i.e. Even if you could find a
LOCATION
for your memcache instance in the cloud, Google's own library would ignore it.