Rewrite cache decorator to use format string

This is easier to read than having to understand the arguments 1…n of
the cache decorator are ‘magic’, and gives us more flexibility about
how the cache keys are formatted, eg being able to add words in the
middle of them.

Also changes the key format for all templates to be
`service-{service_id}-templates` instead of `templates-{service_id}`
because then it’s clearer what the ID represents.
This commit is contained in:
Chris Hill-Scott
2018-04-20 16:32:02 +01:00
parent b28e8691a6
commit 06de94f1c5
6 changed files with 80 additions and 91 deletions

View File

@@ -44,8 +44,8 @@ class InviteApiClient(NotifyAdminAPIClient):
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),
data=data)
@cache.delete('service', 'service_id')
@cache.delete('user', 'invited_user_id')
@cache.delete('service-{service_id}')
@cache.delete('user-{invited_user_id}')
def accept_invite(self, service_id, invited_user_id):
data = {'status': 'accepted'}
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),