Invalidate domains cache when received an event affecting it

When events handling is enabled, use it for cache invalidation too.
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-13 14:55:26 +02:00
parent 57b87da9d1
commit 88b559d985
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -176,8 +176,13 @@ class EventsDispatcher(object):
def handle(self, subject, event, **kwargs):
'''Call handlers for given event'''
if subject:
if event in ['property-set:name']:
self.app.domains.clear_cache()
subject = self.app.domains[subject]
else:
# handle cache refreshing on best-effort basis
if event in ['domain-add', 'domain-delete']:
self.app.domains.clear_cache()
subject = None
for handler in self.handlers.get(event, []):
handler(subject, event, **kwargs)