From 5830d8b8401552d8468a6357901bdedfa8f332ea Mon Sep 17 00:00:00 2001
From: Pouria Hadjibagheri
Date: Sat, 23 Oct 2021 13:51:41 +0100
Subject: [PATCH] updates workflow to retrieve single items before checking
iters
---
app/caching/redis.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/app/caching/redis.py b/app/caching/redis.py
index f4fe2e1..a7ed660 100644
--- a/app/caching/redis.py
+++ b/app/caching/redis.py
@@ -252,6 +252,16 @@ async def _execute(self, *args, **kwargs):
if isinstance(cache_key, (str, bytes)) and results is not None:
return self.process_cache_results(results)
+ elif isinstance(cache_key, (str, bytes)):
+ results = await self.func(
+ request,
+ *bound_inputs.args,
+ area_id=area_id,
+ area_type=area_type,
+ **bound_inputs.kwargs
+ )
+ db_results = self.process_db_results(results)
+ await self._cache_results(redis, cache_key, db_results)
elif hasattr(cache_key, "__iter__"):
for index, (key, res) in enumerate(zip(cache_key, results)):
if res is not None:
@@ -269,16 +279,6 @@ async def _execute(self, *args, **kwargs):
results[index] = self.process_db_results(db_res)
await self._cache_results(redis, key, results[index])
- elif isinstance(cache_key, str):
- results = await self.func(
- request,
- *bound_inputs.args,
- area_id=area_id,
- area_type=area_type,
- **bound_inputs.kwargs
- )
- db_results = self.process_db_results(results)
- await self._cache_results(redis, cache_key, db_results)
elif area_id is None:
results = await self.func(
request,