AutomationDev85 commented on code in PR #30704:
URL: https://github.com/apache/airflow/pull/30704#discussion_r1172235531


##########
airflow/utils/helpers.py:
##########
@@ -45,6 +45,15 @@
 S = TypeVar("S")
 
 
+def get_value_with_cache(cache: dict, key: str, insert_fn: Callable, *arg, 
**kwargs) -> Any:
+    """Returns value from cache or function"""
+    return_value = cache.get(key)
+    if not return_value:
+        return_value = cache[key] = insert_fn(*arg, **kwargs)
+
+    return return_value

Review Comment:
   Thanks for the feedback. I like the new name for the function! 
   I'm using `if not return_value` because if the cache returns empty value, I 
think the best way is to call do_get_value to make sure that the right and 
latest value is used and not the cached value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to