Created
September 25, 2013 11:01
-
-
Save kezabelle/6698089 to your computer and use it in GitHub Desktop.
Thing I want for caching in Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welp, this is just a poor implementation of Django ticket #12982. Oh well.