thadeusb/flask-cache — pull request #66 by lnielsen-cern (2013-04-23 09:31:19+00:00)
Title: Fix issue with Jinja2 cache-tag not deleting and change template tag to use stable keys

**Fix issue with Jinja2 cache-tag not deleting keys:**

* The ```{% cache "del" ... %}``` tag does not delete the keys when
the timeout is set to "del". be4543a fixes this issue,
and adds a test case.

**Change cache-tag to use stable keys:**
The current cache-template tag generates cache keys based on the template name,
line number and possible additional keys. Especially the lineno make it hard to
have stable and predictable cache keys which can be invalidated from outside
the template when underlying data changes. Also, since the filename was used
the cache-tag was not usable when rendering a template directly from a string.

dc1ca07 changes the template tag to require a fragment name:
```
{% cache timeout, "fragmentname" %}
{% cache timeout, "fragmentname", "vary_on1", ... %}
```

and the cache key can easily be generate via a new method:
```
from flask.ext.cache import make_template_fragment_key
make_template_fragment_key("fragmentname")
cache.delete(key)
```

Backward incompatible changes:
* ```{% cache timeout %}``` will no long work. Should be replace with ```{% cache timeout "fragmentname "%}```
* Possible key collision for old keys if same fragment name is used.