Skip to content

Commit

Permalink
updates workflow to retrieve single items before checking iters
Browse files Browse the repository at this point in the history
  • Loading branch information
xenatisch committed Oct 23, 2021
1 parent 6664c26 commit 5830d8b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/caching/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down

0 comments on commit 5830d8b

Please sign in to comment.