As this happens, I have migrated the Django application (1.6.5) to GAE in the last few days (GAE Development SDK 1.9.6). I don't have much need for caching right now, but it's good to know this if I need it.
django.core.cache.backends.memcached.MemcachedCache ( , , python-memcached libs)
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
GAE :
RuntimeError: Unable to create a new session key. It is likely that the cache is unavailable.
...
... , , API Google Django Memcached, , lib python-memcached, SDK. python, my_project/backends.py:
import pickle
from django.core.cache.backends.memcached import BaseMemcachedCache
class GaeMemcachedCache(BaseMemcachedCache):
"An implementation of a cache binding using google app engine memcache lib (compatible with python-memcached)"
def __init__(self, server, params):
from google.appengine.api import memcache
super(GaeMemcachedCache, self).__init__(server, params,
library=memcache,
value_not_found_exception=ValueError)
@property
def _cache(self):
if getattr(self, '_client', None) is None:
self._client = self._lib.Client(self._servers, pickleProtocol=pickle.HIGHEST_PROTOCOL)
return self._client
:
CACHES = {
'default': {
'BACKEND': 'my_project.backends.GaeMemcachedCache',
}
}
! , , , .
google.appengine.api.memcache.__init__.py GAE SDK, :
def __init__(self, servers=None, debug=0,
pickleProtocol=cPickle.HIGHEST_PROTOCOL,
pickler=cPickle.Pickler,
unpickler=cPickle.Unpickler,
pload=None,
pid=None,
make_sync_call=None,
_app_id=None):
"""Create a new Client object.
No parameters are required.
Arguments:
servers: Ignored; only for compatibility.
...
. LOCATION memcache , Google .