thadeusb/flask-cache — pull request #13 by singingwolfboy (2011-12-11 04:35:26+00:00)
Title: abstracting cache_key, cache_timeout, and original function out of decorated function

This branch makes the internals of Flask-Cache more accessible to developers. The
function returned by the cached() decorator has three attributes on it: `cache_key`,
a string containing the key used to cache the results of the function;
`cache_timeout`, the same value passed to the decorator, and `uncached`, the original
function that was decorated. These attributes are both readable and writable, and
the decorated function will pick up changes to these attributes. This allows
developers to access and modify the cache entry for a function (useful for prewarming
caches, for example), access and modify cache timeouts (adjusting caches on the fly),
and an easy way to manually call the original function without caching.

The memoized() decorator has the same attributes, but instead of a `cache_key` string
attribute, it has a `make_cache_key` function, which accepts the same arguments
that the underlying function does.

I've added some unit tests, but I haven't updated the documentation -- I'm not familiar with the documentation style, so I was hoping that you could give me some suggestions, or update it yourself. This change will definitely require a bump in the minor version, as per [semantic versioning](http://www.semver.org).