jason810496 commented on code in PR #71814:
URL: https://github.com/apache/airflow/pull/71814#discussion_r3811593746
##########
airflow-core/src/airflow/models/dagbag.py:
##########
@@ -79,26 +80,30 @@ def __init__(
Initialize DBDagBag.
:param load_op_links: Should the extra operator link be loaded when
de-serializing the DAG?
- :param cache_size: Size of LRU cache. If None or 0, uses unbounded
dict (no eviction).
- :param cache_ttl: Time-to-live for cache entries in seconds. If None
or 0, no TTL (LRU only).
+ :param cache_size: Max cached entries. 0 or None means no size limit.
+ :param cache_ttl: Seconds until a cached entry expires, applied with
or without a size limit.
+ 0 or None disables TTL. With neither a size limit nor a TTL the
cache never evicts.
"""
self.load_op_links = load_op_links
self._dags: MutableMapping[UUID | str, _CacheEntry] = {}
self._use_cache = False
self._revalidation_interval = conf.getint("core",
"min_serialized_dag_update_interval")
- # Initialize bounded cache if cache_size is provided and > 0
- if cache_size and cache_size > 0:
- if cache_ttl and cache_ttl > 0:
- self._dags = TTLCache(maxsize=cache_size, ttl=cache_ttl)
- else:
- self._dags = LRUCache(maxsize=cache_size)
+ # A TTL applies with or without a size limit: an uncapped TTLCache is
what lets
+ # ``dag_cache_size = 0`` mean "no size limit" rather than "no eviction
at all".
+ size = max(cache_size or 0, 0)
+ ttl = max(cache_ttl or 0, 0)
Review Comment:
The caller site will raise the warning against the negative value.
https://github.com/apache/airflow/blob/d74fbff4e32108df9276c9a907536d7da710f8dc/airflow-core/src/airflow/api_fastapi/common/dagbag.py#L36-L55
Since this PR change the behavior anyway, so no harm to raise ValueError on
negative 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]