Skip to content

Commit

Permalink
metadata_cache: fix disk cache
Browse files Browse the repository at this point in the history
Also add a unit test
  • Loading branch information
Corentin Chary committed May 24, 2018
1 parent 59dbdbc commit d082af9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion biggraphite/metadata_cache.py
Expand Up @@ -523,7 +523,7 @@ def _cache_set(self, metric_name, metric):

def stats(self):
"""Count number of cached entries."""
ret = super(MemoryCache, self).stat()
ret = super(DiskCache, self).stats()
ret['root'] = self.__env.stat(),
for name, database in self.__databases.items():
with self.__env.begin(database, write=False) as txn:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_metadata_cache.py
Expand Up @@ -127,6 +127,19 @@ def test_repair_shard(self):
self.assertEqual(self.metadata_cache.miss_count, 1)


def test_stats(self):
ret = self.metadata_cache.stats()
self.assertNotEqual(len(ret), 0)

metric_name = "a.b.test"
metric = bg_test_utils.make_metric(metric_name)

self.metadata_cache.create_metric(metric)

ret = self.metadata_cache.stats()
self.assertNotEqual(len(ret), 0)


class TestDiskCache(CacheBaseTest, bg_test_utils.TestCaseWithFakeAccessor):

CACHE_CLASS = bg_metadata_cache.DiskCache
Expand Down

0 comments on commit d082af9

Please sign in to comment.