From ba8718054bb210dcc7f43d5ef943def665f23632 Mon Sep 17 00:00:00 2001 From: marcsello Date: Sat, 11 Dec 2021 00:08:17 +0100 Subject: [PATCH] reduced redis access count --- birb_scheduler_teller/views/assignment_view.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/birb_scheduler_teller/views/assignment_view.py b/birb_scheduler_teller/views/assignment_view.py index 33dc6fd..f784c67 100644 --- a/birb_scheduler_teller/views/assignment_view.py +++ b/birb_scheduler_teller/views/assignment_view.py @@ -66,12 +66,13 @@ class AssignmentView(FlaskView): if default_target: target_site = default_target - redis_client.set(schedule_store_key, default_target) + redis_client.set(schedule_store_key, default_target, ex=current_app.config['DEVICE_TIMEOUT']) - # Update (or set) TTL - redis_client.expire( - schedule_store_key, - current_app.config['DEVICE_TIMEOUT'] - ) + else: + # Just Update TTL + redis_client.expire( + schedule_store_key, + current_app.config['DEVICE_TIMEOUT'] + ) return jsonify(self._resolve_response(target_site))