Skip to content

Instantly share code, notes, and snippets.

@narfdotpl
Created August 15, 2011 09:58
Show Gist options
  • Save narfdotpl/1145983 to your computer and use it in GitHub Desktop.
Save narfdotpl/1145983 to your computer and use it in GitHub Desktop.
invalidate Johnny Cache
#!/usr/bin/env python
# encoding: utf-8
"""
Invalidate Johnny Cache's cache for given models outside "normal Django"
(e.g. in a management command).
"""
from johnny.cache import invalidate
from johnny.middleware import QueryCacheMiddleware
from stupid.models import Cheezburger, Kitten
def _main():
QueryCacheMiddleware()
invalidate(Cheezburger, Kitten)
if __name__ == '__main__':
_main()
@alecklandgraf
Copy link

Thanks, had issues invalidation cache from django shell, probably because I wasn't calling QueryCacheMiddleware() first.

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