Merge pull request #18687 from edx/ahsan/LEARNER-5967-Investigate-excessive-program-cache-miss

Updated log to check which site cache are miss
This commit is contained in:
Ahsan Ul Haq
2018-07-31 17:59:56 +05:00
committed by GitHub
2 changed files with 4 additions and 2 deletions

View File

@@ -66,7 +66,9 @@ class TestGetPrograms(CacheIsolationTestCase):
# When called before UUIDs are cached, the function should return an
# empty list and log a warning.
self.assertEqual(get_programs(self.site), [])
mock_warning.assert_called_once_with('Failed to get program UUIDs from the cache.')
mock_warning.assert_called_once_with(
'Failed to get program UUIDs from the cache for site {}.'.format(self.site.domain)
)
mock_warning.reset_mock()
# Cache UUIDs for all 3 programs.

View File

@@ -63,7 +63,7 @@ def get_programs(site, uuid=None):
return program
uuids = cache.get(SITE_PROGRAM_UUIDS_CACHE_KEY_TPL.format(domain=site.domain), [])
if not uuids:
logger.warning('Failed to get program UUIDs from the cache.')
logger.warning('Failed to get program UUIDs from the cache for site {}.'.format(site.domain))
programs = cache.get_many([PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) for uuid in uuids])
programs = list(programs.values())