Cache organisations, not just domains in Redis

This should make the ‘All organisations’ page load a lil’ bit quicker.
Still worth caching the domains separately so the response is smaller
when we only care about domains. This is because the code that uses the
domains is part of the sign up flow, so it’s really important that it’s
snappy.
This commit is contained in:
Chris Hill-Scott
2019-06-14 11:10:57 +01:00
parent c7325576d6
commit 8f9ade7a8b
4 changed files with 87 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
class OrganisationsClient(NotifyAdminAPIClient):
@cache.set('organisations')
def get_organisations(self):
return self.get(url='/organisations')
@@ -30,6 +31,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
return None
raise error
@cache.delete('organisations')
def create_organisation(self, name):
data = {
"name": name
@@ -37,6 +39,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
return self.post(url="/organisations", data=data)
@cache.delete('domains')
@cache.delete('organisations')
def update_organisation(self, org_id, **kwargs):
return self.post(url="/organisations/{}".format(org_id), data=kwargs)