Django Memcached

Make Django Memcached super easy with Redis Labs

Redis Labs’ products and services enable running Memcached buckets in a highly available and auto-scalable manner, with predictable top performance.

Redise Pack lets you install an enterprise grade Memcached cluster in your environment of choice, whether an on-premises data-center or your preferred cloud platform. It gives you full control of your data and configuration – no clustering or sharding knowledge required!

Memcached Cloud is a fully managed cloud service for hosting and running Memcached datasets in a highly available and scalable manner, with predictable and stable top performance. It provides a storage engine for standard Memcached, as well as in-memory replication and instant auto-failover within the same data center or across data centers. The service completely frees developers from dealing with nodes, clusters, scaling, data persistence issues or failure recovery.

Using Memcached with Django

To use Memcached as a cache for your Django website
edit your Django’s settings.py file as described in the “Django’s cache framework” page of Django’s documentation. Add the following CACHE settings to settings.py:

os.environ[‘MEMCACHE_SERVERS’] = ‘hostname:port’ os.environ[‘MEMCACHE_USERNAME’] = ‘username’
os.environ[‘MEMCACHE_PASSWORD’] = ‘password’

CACHES = {

 'default': {
     'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
     'BINARY': True
 }

}

  • In line 1, the value should be your bucket’s endpoint
  • In line 2, the value should be your bucket’s username
  • In line 3, the value should be your bucket’s password

Note: make sure you have django-pylibmc installed on your Django server by running the following command:

$ sudo pip install django-pylibmc

For more information on using Redis Labs’ products and services with Django please see the Howto page.