class memoize(object): def __init__(self, func): self.func = func self.mc = EcsCache() def __call__(self, *args, **kw): return self._wrap(*args, **kw) def _wrap(self, *args, **kw): key = make_key(args, kw, self.func) cache = self.mc.get(key) if cache is not None: return cache else: res = self.func(*args, **kw) self.mc.set(key, res) return res