mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
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:
@@ -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')
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user