Reduce TTL to 1 hour for get_count_of_live_services_and_organisations

This stat is shown on a few of our pages, such as our homepage,
the performance page and also a platform admin page
and is currently catched for the
default TTL of 1 week. I think there is no reason we can't make
this only cache once an hour and give slightly more up to date stats
which will update more regularly.

This mimics the approach and also the TTL choice of 1 hour that has
been added for the performance page (although there is no
particular bug here to fix, it is just nice to have slightly more up
up to date data).

Note, the API call only takes about 0.3 seconds at the moment
so it is not particularly intensive on the DB to run this more
regularly.
This commit is contained in:
David McDonald
2021-11-24 18:10:30 +00:00
parent 6acc7838e2
commit 20cc1e230f
2 changed files with 2 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ class StatusApiClient(NotifyAdminAPIClient):
def get_status(self, *params):
return self.get(url='/_status', *params)
@cache.set('live-service-and-organisation-counts')
@cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organisations(self):
return self.get(url='/_status/live-service-and-organisation-counts')

View File

@@ -33,7 +33,7 @@ def test_sets_value_in_cache(mocker):
mock_redis_set.assert_called_once_with(
'live-service-and-organisation-counts',
'{"data_from": "api"}',
ex=604800
ex=3600
)