Skip to content
Automatic Django memcached configuration on Heroku.
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Automatic Django memcached configuration on Heroku.

Deploying memcached is easy


To install django-heroku-memcacheify, simply run pip install django-heroku-memcacheify and you'll get the latest version installed automatically.


Modify your Django file, and set:

from memcacheify import memcacheify

CACHES = memcacheify()

That's it.

Assuming you have a memcache server available to your application on Heroku, it will instantly be available. If you have no memcache addon provisioned for your app, memcacheify will default to using local memory caching as a backup :)

Heroku Setup

Now that you've got Django configured to use memcache, all you need to do is install one of the two excellent memcache addons that Heroku provides!

  • Memcache - Been around longer, but pretty expensive, or
  • MemCachier - Newer, less expensive.

Let's say I want to install the memcachier addon, I could simply run:

$ heroku addons:add memcachier:25
$ heroku config
MEMCACHIER_PASSWORD   => l0nGr4ndoMstr1Ngo5strang3CHaR4cteRS

The example above will provision a free 25m memcache server for your application. Assuming everything worked, heroku config's output should show that you now have 3 new environment variables set.

Testing Your Cache

If you don't trust me, and want to make sure your caching is working as expected, you may do the following:

$ heroku run python shell
Running python shell attached to terminal... up, run.1
Python 2.7.2 (default, Oct 31 2011, 16:22:04)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core.cache import cache
>>> cache.set('memcache', 'ify!')
>>> cache.get('memcache')

Assuming everything is working, you should be able to set and retrieve cache keys.


If you're confused, you should probably read:


Build Status

Want to run the tests? No problem:

$ git clone git://
$ cd django-heroku-memcacheify
$ python develop
$ pip install -r requirements.txt  # Install test dependencies.
$ nosetests
Ran 13 tests in 0.166s



v0.3: 6-27-2012

- Fixing broken memcachier support.

v0.2: 5-22-2012

- Adding support for memcachier Heroku addon.
- Updating documentation.
- Refactoring implementation for clarity.
- Adding better tests.

v0.1: 5-2-2012

- Initial release!
Something went wrong with that request. Please try again.