Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you want Memcached to behave like normal RAM and page to disk when it is full. It doesn't by default, but you can imitate it by writing your own cache backend as @AlexanderAfanasiev mentioned. The implementation would be something along these lines:</p> <p>First, define three caches:</p> <pre><code>CACHES = { 'default': { 'BACKEND': 'myapp.cache.DoubleCache', }, 'memcached': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', }, 'filecache': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': '/foo/bar', } } </code></pre> <p>Then, in myapp/cache.py:</p> <pre><code>from django.core.cache.backends.base import BaseCache from django.core.cache import get_cache, cache mem_cache = get_cache('memcached') file_cache = get_cache('filecache') class DoubleCache(BaseCache): def get(self, key, default=None, version=None): result = mem_cache.get(key, default=default, version=version) if result: return result else: return file_cache.get(key, default=default, version=version) def set(self, key, value, timeout=None, version=None, client=None, _add_only=False): memcache_result = mem_cache.set(key, value, timeout=timeout, version=version, client=client, _add_only=_add_only) file_result = file_cache.set(key, value, timeout=timeout, version=version, client=client, _add_only=_add_only) return memcache_result </code></pre> <p>This will always store values in both caches. It will retrieve values from Memcached, and if it misses, will try the file_cache. That means that Memcached can manage its own roll-off and only the oldest hits will have to fall back to file_cache. This is what you'd want.</p> <p>Of course, you'll also have to implement the rest of the cache functions like <code>delete()</code>, <code>get_many()</code>, etc. Hopefully this gets you on the right path.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload