Skip to content

Instantly share code, notes, and snippets.

@numan
Created July 28, 2013 00:33
Show Gist options
  • Save numan/6096878 to your computer and use it in GitHub Desktop.
Save numan/6096878 to your computer and use it in GitHub Desktop.
customized cached_with for django-cache-machine to use with django-tastypie
from caching.base import cached_with as official_cached_with
def cached_with(obj, f, f_key, timeout=None):
"""Helper for caching a function call within an object's flush list."""
if hasattr(obj, "exists") and not obj.exists():
return f()
return official_cached_with(obj, f, f_key, timeout=timeout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment