mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-14 23:08:07 -04:00
Cache known domains in Redis
The domains lookup is a bit slow because it’s serialising all the organisations in the database. Since we’re putting this in the sign up flow it should feel snappy, so lets cache just the domain bit of it in Redis.
This commit is contained in:
@@ -10,8 +10,9 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
def get_organisations(self):
|
||||
return self.get(url='/organisations')
|
||||
|
||||
@cache.set('domains')
|
||||
def get_domains(self):
|
||||
return set(chain.from_iterable(
|
||||
return list(chain.from_iterable(
|
||||
organisation['domains']
|
||||
for organisation in self.get_organisations()
|
||||
))
|
||||
@@ -35,6 +36,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
}
|
||||
return self.post(url="/organisations", data=data)
|
||||
|
||||
@cache.delete('domains')
|
||||
def update_organisation(self, org_id, **kwargs):
|
||||
return self.post(url="/organisations/{}".format(org_id), data=kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user