mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Cache service data retention in Redis
Adds caching for service data retention. This removes separate API client methods to retrieve individual data retention records by id or type in favor of a single method that fetches and caches all retention settings configured for the service. This makes it much easier to invalidate cache when settings change. Lookup by id or type is provided by helper methods in the service model.
This commit is contained in:
@@ -488,6 +488,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
}
|
||||
return self.post("/service/{}/delivery-receipt-api".format(service_id), data)
|
||||
|
||||
@cache.delete('service-{service_id}-data-retention')
|
||||
def create_service_data_retention(self, service_id, notification_type, days_of_retention):
|
||||
data = {
|
||||
"notification_type": notification_type,
|
||||
@@ -496,20 +497,16 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
|
||||
return self.post("/service/{}/data-retention".format(service_id), data)
|
||||
|
||||
@cache.delete('service-{service_id}-data-retention')
|
||||
def update_service_data_retention(self, service_id, data_retention_id, days_of_retention):
|
||||
data = {
|
||||
"days_of_retention": days_of_retention
|
||||
}
|
||||
return self.post("/service/{}/data-retention/{}".format(service_id, data_retention_id), data)
|
||||
|
||||
@cache.set('service-{service_id}-data-retention')
|
||||
def get_service_data_retention(self, service_id):
|
||||
return self.get("/service/{}/data-retention".format(service_id))
|
||||
|
||||
def get_service_data_retention_by_notification_type(self, service_id, notification_type):
|
||||
return self.get("/service/{}/data-retention/notification-type/{}".format(service_id, notification_type))
|
||||
|
||||
def get_service_data_retention_by_id(self, service_id, data_retention_id):
|
||||
return self.get("service/{}/data-retention/{}".format(service_id, data_retention_id))
|
||||
|
||||
|
||||
service_api_client = ServiceAPIClient()
|
||||
|
||||
Reference in New Issue
Block a user