django-query-caching

Caches the results of SQL queries transparently.


Keywords
django, query, cache
License
BSD-3-Clause
Install
pip install django-query-caching==0.1.1

Documentation

= Django Query Caching =
Caches the results of SQL queries transparently.
FYI, this isn't complete yet, there's probably still a lot of bugs.
Also, this whole project might just be a bad idea since it caches everything. I'll probably add options for excluding tables and limiting the size of queries that can be cached. Even then, testing will need to be done to make sure this actually speeds things up.
This project was developed using Django 1.2.1.

= Usage =
Place this directory in your Django project or on your Python path, then add 'django_query_caching' to your INSTALLED_APPS. That's it.

= Why? =
I'd written a CachedManager implementation that caches whole QuerySets, but it was really only good for doing things like MyModel.objects.all(). filter() and the other methods would still hit the database (writing custom filter() and exclude() methods to iterate over the whole cached QuerySet wouldn't be practical), as would anything to do with a RelatedManager. Using the Django Debug Toolbar, I also noticed that the same queries were sometimes being executed 2-3 times per page load, because they were occurring in separate parts of my application and the built in QuerySet cache isn't shared across instances. I decided the simplest way to solve all these problems at once was to cache the results of the SQL statements themselves.

= Contributing =
You can fork this project on GitHub: http://github.com/SeanHayes/django_query_caching.

= License =
This project is licensed under the BSD License.
http://www.opensource.org/licenses/bsd-license.php

== Links ==
https://github.com/SeanHayes/django-query-caching
http://pypi.python.org/pypi/django-query-caching
http://djangopackages.com/packages/p/django-query-caching/

== Alternatives ==
http://packages.python.org/johnny-cache/
https://github.com/jbalogh/django-cache-machine