MemCachier in Heroku Just Got Easier in Django!

Randall Degges just added MemCachier to his Django automatic memcache module, which makes setting up MemCachier in Django as easy as installing a module.  All you need to do is:

$ heroku addons:add memcachier:25
$ pip install django-heroku-memcacheify

And add the following to

from memcacheify import memcacheify
import os
os.environ['MEMCACHE_SERVERS'] = os.environ.get('MEMCACHIER_SERVERS', '')
os.environ['MEMCACHE_USERNAME'] = os.environ.get('MEMCACHIER_USERNAME', '')
os.environ['MEMCACHE_PASSWORD'] = os.environ.get('MEMCACHIER_PASSWORD', '')
CACHES = memcacheify()

Then, to test if it’s working, run:

$ 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')

Checkout django-heroku-memcacheify on github for more information.  Thanks, Randall!

UPDATE: these instructions will be even easier once this pull request is merged.  Once it’s merged, you won’t need to muck with environment variables at all.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s