Fetching contributors…
Cannot retrieve contributors at this time
53 lines (35 sloc) 1.67 KB


The main class is cacheback.base.Job. The methods that are intended to be called from client code are:

It has some class properties than can be used to configure simple behaviour:

There are also several methods intended to be overridden and customised:

Queryset jobs

There are two classes for easy caching of ORM reads. These don't need subclassing but rather take the model class as a __init__ parameter.

Example usage:

from django.contrib.auth import models
from django.shortcuts import render
from import QuerySetGetJob, QuerySetFilterJob

def user_detail(request, username):
    user = QuerySetGetJob(models.User).get(username=username)
    return render(request, 'user.html',
                  {'user': user})

def staff(request):
    staff = QuerySetFilterJob(models.User).get(is_staff=True)
    return render(request, 'staff.html',
                  {'users': staff})

These classes are helpful for simple ORM reads but won't be suitable for more complicated queries where filter is chained together with exclude.