From 259559f2246369e624dbbca39b44d93d3d82bc8e Mon Sep 17 00:00:00 2001 From: Logan Hanks Date: Wed, 8 Feb 2012 12:00:24 -0800 Subject: [PATCH] Access CacheStats from Thing._byID more safely. --- r2/r2/lib/db/thing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/db/thing.py b/r2/r2/lib/db/thing.py index 95d23d2f1..b4b112dd6 100644 --- a/r2/r2/lib/db/thing.py +++ b/r2/r2/lib/db/thing.py @@ -352,13 +352,15 @@ class DataThing(object): stale=False): ids, single = tup(ids, True) prefix = thing_prefix(cls.__name__) - cache_stats = stats.CacheStats(g.stats, 'sgm.%s' % cls.__name__) if not all(x <= tdb.MAX_THING_ID for x in ids): raise NotFound('huge thing_id in %r' % ids) def count_found(ret, still_need): - cache_stats.cache_report(hits=len(ret), misses=len(still_need)) + cache.stats.cache_report(hits=len(ret), misses=len(still_need)) + + if not cache.stats: + count_found = None def items_db(ids): items = cls._get_item(cls._type_id, ids)