thadeusb/flask-cache — pull request #69 by bslatkin (2013-07-16 06:22:57+00:00)
Title: Adds per-instance cache versioning for memoize()

Adds the 'per_instance' keyword to memoize().

If set to True, the cache key versioning used will be scoped to the function's first argument (i.e., a method's bound object). This lets you cache many different calls to one memoized function for a single object (like a user) and later clear all data cached for that object with a single call to delete_memoized.

Importantly: This is achieved with no additional round-trips to the cache for the per-method version. The code uses the get_many/set_many functions so the only difference is the number of keys get/set.

Various other clean-up including:
- Unify version setting code in _memoize_version
- Make _memoize_kwargs_to_args protected
- Only one call-site for function_namespace, making it easier to follow
- Updated docs with notes about per_method usage

Let me know what I need to do to land this! Thanks.