Skip to content

Commit

Permalink
Add stale cache support to @memoize.
Browse files Browse the repository at this point in the history
  • Loading branch information
spladug committed Dec 1, 2011
1 parent 3737592 commit 2ac898f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions r2/r2/lib/memoize.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

make_lock = g.make_lock

def memoize(iden, time = 0):
def memoize(iden, time = 0, stale=False):
def memoize_fn(fn):
from r2.lib.memoize import NoneResult
def new_fn(*a, **kw):
Expand All @@ -40,7 +40,7 @@ def new_fn(*a, **kw):

key = make_key(iden, *a, **kw)

res = None if update else cache.get(key)
res = None if update else cache.get(key, stale=stale)

if res is None:
# not cached, we should calculate it.
Expand Down

0 comments on commit 2ac898f

Please sign in to comment.