django-better-cache

Software Screenshot:
django-better-cache
Software Details:
Version: 0.6
Upload Date: 20 Feb 15
Developer: Calvin Spealman
Distribution Type: Freeware
Downloads: 12

Rating: 2.0/5 (Total Votes: 1)

django-better-cache is a replacement for the default cache template tag library from Django.

It is a better version of {% cache %}

What is better about Better Cache?

 - Nested cache fragments inherit the variables their parent fragments key on
 - Parent cache fragments can be given additional keys by their child cache fragments

An example:

    {% cache 500 "outer" x %}
        y = {{ y }}< br / >
        {% cache 500 "inner" y %}
            x = {{ x }}< br / >
        {% endcache %}
    {% endcache %}


In the default {% cache %} tag from Django, the inner fragment will not be rerendered when x changes, because only the outer fragment uses that as a key variable. The outer fragment will not update with y changes, because only the inner fragment uses that.

With Better Cache, x and y affect both, so fragments will be re-rendered when any important variable changes.

Better Cache also allows a syntax of giving defaults to key variables:

    {% cache 500 "test" x=10 %}

Controlling inheritence

You don't always want the outer cache fragments to invalidate when variables only important to the inner fragment changes. In some cases, the inner fragment is allowed to get stale if it stays cached longer as part of the parent, so we want a way to disable the inheritence of the variables.

You can do this with the `local` modifier. All modifiers after the `local` will affect only this cache fragment, not its parent.

    {% cache 500 "outer" x %}
        y = {{ y }}< br / >
        {% cache 500 "inner" local y %}
            x = {{ x }}< br / >
        {% endcache %}
    {% endcache %}


Plans

 - on-demand invalidation of fragments based on mappings through an ORM-like interface

Requirements:

  • Python
  • Django

Other Software of Developer Calvin Spealman

django-sanitizer
django-sanitizer

14 Apr 15

Comments to django-better-cache

Comments not found
Add Comment
Turn on images!