From 8a7d2a8990fbf983be1af19a6c42e891d65fbe99 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Mon, 19 Mar 2012 17:09:41 -0700 Subject: [PATCH] Add debug logging to the new query cache. --- r2/r2/models/query_cache.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/r2/r2/models/query_cache.py b/r2/r2/models/query_cache.py index 4e087da84..78d06e461 100644 --- a/r2/r2/models/query_cache.py +++ b/r2/r2/models/query_cache.py @@ -16,6 +16,7 @@ from r2.lib.utils import flatten, to36 CONNECTION_POOL = g.cassandra_pools['main'] PRUNE_CHANCE = g.querycache_prune_chance MAX_CACHED_ITEMS = 1000 +LOG = g.log # if cjson is installed, use it. it's faster. @@ -172,6 +173,10 @@ class CachedQuery(CachedQueryBase): def __ne__(self, other): return not self.__eq__(other) + def __repr__(self): + return "%s(%s, %r)" % (self.__class__.__name__, + self.model.__name__, self.key) + class MergedCachedQuery(CachedQueryBase): def __init__(self, queries): @@ -205,6 +210,8 @@ class CachedQueryMutator(object): if not things: return + LOG.debug("Inserting %r into query %r", things, query) + query._insert(self.mutator, things) if (random.random() / len(things)) < PRUNE_CHANCE: @@ -214,12 +221,15 @@ class CachedQueryMutator(object): if not things: return + LOG.debug("Deleting %r from query %r", things, query) + query._delete(self.mutator, things) def send(self): self.mutator.send() if self.to_prune: + LOG.debug("Pruning queries %r", self.to_prune) CachedQuery._prune_multi(self.to_prune)