Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Created September 25, 2013 11:01
Show Gist options
  • Save kezabelle/6698089 to your computer and use it in GitHub Desktop.
Save kezabelle/6698089 to your computer and use it in GitHub Desktop.
Thing I want for caching in Django
class MyCacheBackendThing(Ellipsis):
def get_or_set(self, key, timeout, setter):
data = self.get(key, None)
if data is None:
data = setter
if callable(data):
data = data()
self.set(key, data, timeout)
return data
@kezabelle
Copy link
Author

Welp, this is just a poor implementation of Django ticket #12982. Oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment