Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Django cache tools originally developed for Ella CMS

Project Description

Django cache tools originally developed for Ella CMS. It contains few helpful caching tools (such as cached ForeignKey, functions for caching object/objects, decorator for caching function/method, etc.)

Usage for models

In models.py you can use CachedForeignKey:

from __future__ import unicode_literals
from django.db import models
from cache_tools.fields import CachedForeignKey


@python_2_unicode_compatible
class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.question_text


@python_2_unicode_compatible
class Choice(models.Model):
    question = CachedForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text

Usage for caching function

In whatever.py you can use cache_this:

from cache_tools.utils import cache_this
from .models import Question


@cache_this(lambda *args, **kwargs: 'my_app_all_questions_cache_key')
def get_all_guestions():
    return list(Question.objects.all().order_by('pk'))

Build status

Master branch:
Release History

Release History

This version
History Node

0.6.3

History Node

0.6.2

History Node

0.6.1

History Node

0.6.0

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dj_cache_tools-0.6.3-py2.py3-none-any.whl (8.1 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Aug 25, 2016
dj-cache-tools-0.6.3.tar.gz (5.8 kB) Copy SHA256 Checksum SHA256 Source Aug 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting