Package: django-heroku-memcacheify
django-heroku-memcacheifyAutomatic Django memcached configuration on Heroku.InstallTo installdjango-heroku-memcacheify, simply runpip install django-heroku-memcacheifyand you'll get the latest version
installed automatically.NOTE: If you'd like to install this locally, you'll need to have thelibmemcached-devlibraries installed for this to compile properly. On
Debian and Ubuntu you can install this by runningsudo aptitude -y install libmemcached-dev. If you're using a Mac, you can usehomebrewand runbrew install libmemcached.UsageModify your Djangosettings.pyfile, and set:frommemcacheifyimportmemcacheifyCACHES=memcacheify()Next, ensure pylibmc is present in yourrequirements.txtfile (or one
included from it), so the Heroku Python buildpack will detect the necessary
C dependencies and 'bootstrap' your application.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,memcacheifywill default to using local memory caching as a backup :)Heroku SetupNow that you've got Django configured to use memcache, all you need to do is
install one memcache addons that Heroku provides!I personally recommendMemCachier--
they're stable, cheap, great!Let's say I want to install thememcachieraddon, I could simply run:$herokuaddons:addmemcachier:25
$herokuconfig
...MEMCACHIER_SERVERS=>memcachier1.example.netMEMCACHIER_USERNAME=>bobslobMEMCACHIER_PASSWORD=>l0nGr4ndoMstr1Ngo5strang3CHaR4cteRS
...The example above will provision afree25m memcache server for your
application. Assuming everything worked,heroku config's output should show
that you now have 3 new environment variables set.Local DevelopmentIf you have a memcached server locally for development that doesn't support
authentication, you can still use memcache by setting an environment variableMEMCACHEIFY_USE_LOCAL=True.This will set the default cache todjango_pylibmc.memcached.PyLibMCCacheIf there are no environment variables for memcache or memcacheify, the default
cache will be local memorydjango.core.cache.backends.locmem.LocMemCache.Testing Your CacheIf you don't trust me, and want to make sure your caching is working as
expected, you may do the following:$herokurunpythonmanage.pyshell
Runningpythonmanage.pyshellattachedtoterminal...up,run.1
Python2.7.2(default,Oct312011,16:22:04)[GCC4.4.3]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.(InteractiveConsole)>>>fromdjango.core.cacheimportcache
>>>cache.set('memcache','ify!')True
>>>cache.get('memcache')'ify!'>>>Assuming everything is working, you should be able to set and retrieve cache
keys.ReferencesIf you're confused, you should probably read:Heroku's Getting Started GuideHeroku's memcachier Addon DocumentationTestsWant to run the tests? No problem:$gitclonegit://github.com/rdegges/django-heroku-memcacheify.git
$cddjango-heroku-memcacheify
$pythonsetup.pydevelop
...
$pipinstall-rrequirements.txt# Install test dependencies.$flake8
$nosetests
.............
----------------------------------------------------------------------
Ran13testsin0.166s

OKChangelogv1.0.1: 10-10-2021- Fixing PyPI descriptionv1.0.0: 01-04-2016- Update django-pylibmc dependency to >=0.6.1.
- Officially support Python 3.5.
- Stop testing on Python 2.6.v0.8: 11-12-2014- Adding support for memcachedcloud!v0.7: 9-22-2014- Upgrading dependencies (again)!v0.6: 9-20-2014- Upgrading dependencies.v0.5: 12-31-2013- Making the timeout option configurable.
- Removing Python 2.5 support.
- Adding an option to use memcached locally without SASL.
- Updating the README, explaining how to use memcached locally.v0.4: 12-5-2012- Update which allows memcachier users to support multiple servers >:)
  Thanks @alexlod!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!