Use new redis key for service templates and broadcasts

We can drop use of the old key as we no longer need to read data from
the old key. Either data exists in the new key and we read it from there
or data doesn't exist in the new key and we go to the API to get it and
then set it in redis.

Note, the previous commit is important because it means we aren't at
risk of when this commit is being deployed out, of us getting stale data
from the old key.
This commit is contained in:
David McDonald
2020-09-21 16:29:35 +01:00
parent e3baa9ba35
commit a538329d0e
4 changed files with 16 additions and 16 deletions

View File

@@ -258,7 +258,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
_attach_current_user({'postage': postage})
)
@cache.set('template-{template_id}-version-{version}')
@cache.set('service-{service_id}-template-{template_id}-version-{version}')
def get_service_template(self, service_id, template_id, version=None):
"""
Retrieve a service template.
@@ -270,7 +270,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = '{base}/version/{version}'.format(base=endpoint, version=version)
return self.get(endpoint)
@cache.set('template-{template_id}-versions')
@cache.set('service-{service_id}-template-{template_id}-versions')
def get_service_template_versions(self, service_id, template_id):
"""
Retrieve a list of versions for a template