Skip to content

Instantly share code, notes, and snippets.

@powellc
Created May 7, 2013 21:31
Show Gist options
  • Save powellc/5536317 to your computer and use it in GitHub Desktop.
Save powellc/5536317 to your computer and use it in GitHub Desktop.
A nice big caveat for using Johnny Cache to speed up django ORM queries when you also have to use management tasks.

Johnny Cache & Management Commands

Discovered a pretty huge caveat to using Johnny Cache to speed up Django ORM queries.

Johnny Cache is a really great library that can speed up Django sites that are slowing down with large joins and complex data models. Django has a built in ORM caching mechanism, but Johnny Cache takes it one step further.

That said, there are some monsters in the undiscovered ocean. One of the big ones is, I feel, not prominent enough: enabling cache validation and invaldiation when running mangaement commands.

You must enable Johnny Cache some where in your project that gets run everytime manage.py is used. The top level init.py file is a good candidate in most projects. If you don't do that, management commands will leave your views all screwed up and you'll wonder why things that should be published are not.

I learned the hard way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment