Rename keyargs to args in CacheDescriptor
This commit is contained in:
parent
2cd6cb9f65
commit
86eaaa885b
|
@ -180,9 +180,9 @@ class CacheDescriptor(object):
|
||||||
@functools.wraps(self.orig)
|
@functools.wraps(self.orig)
|
||||||
def wrapped(*args, **kwargs):
|
def wrapped(*args, **kwargs):
|
||||||
arg_dict = inspect.getcallargs(self.orig, obj, *args, **kwargs)
|
arg_dict = inspect.getcallargs(self.orig, obj, *args, **kwargs)
|
||||||
keyargs = tuple(arg_dict[arg_nm] for arg_nm in self.arg_names)
|
cache_key = tuple(arg_dict[arg_nm] for arg_nm in self.arg_names)
|
||||||
try:
|
try:
|
||||||
cached_result_d = self.cache.get(keyargs)
|
cached_result_d = self.cache.get(cache_key)
|
||||||
|
|
||||||
observer = cached_result_d.observe()
|
observer = cached_result_d.observe()
|
||||||
if DEBUG_CACHES:
|
if DEBUG_CACHES:
|
||||||
|
@ -192,7 +192,7 @@ class CacheDescriptor(object):
|
||||||
if actual_result != cached_result:
|
if actual_result != cached_result:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Stale cache entry %s%r: cached: %r, actual %r",
|
"Stale cache entry %s%r: cached: %r, actual %r",
|
||||||
self.orig.__name__, keyargs,
|
self.orig.__name__, cache_key,
|
||||||
cached_result, actual_result,
|
cached_result, actual_result,
|
||||||
)
|
)
|
||||||
raise ValueError("Stale cache entry")
|
raise ValueError("Stale cache entry")
|
||||||
|
@ -212,13 +212,13 @@ class CacheDescriptor(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
def onErr(f):
|
def onErr(f):
|
||||||
self.cache.invalidate(keyargs)
|
self.cache.invalidate(cache_key)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
ret.addErrback(onErr)
|
ret.addErrback(onErr)
|
||||||
|
|
||||||
ret = ObservableDeferred(ret, consumeErrors=True)
|
ret = ObservableDeferred(ret, consumeErrors=True)
|
||||||
self.cache.update(sequence, keyargs, ret)
|
self.cache.update(sequence, cache_key, ret)
|
||||||
|
|
||||||
return ret.observe()
|
return ret.observe()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue