mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Add notes about _is_cache_updated logic
This commit is contained in:
parent
c150fe6f0d
commit
469b7e7668
@ -176,12 +176,15 @@ class GitHub(github.Github):
|
||||
self, cache_file: Path, obj_updated_at: Optional[datetime]
|
||||
) -> Tuple[bool, object]:
|
||||
cached_obj = self._get_cached(cache_file)
|
||||
cache_updated = cached_obj.updated_at
|
||||
# We don't want the cache_updated being always old,
|
||||
# for example in cases when the user is not updated for ages
|
||||
cache_updated = max(
|
||||
datetime.fromtimestamp(cache_file.stat().st_mtime), cached_obj.updated_at
|
||||
)
|
||||
if obj_updated_at is None:
|
||||
# When we don't know about the object is updated or not,
|
||||
# we update it once per hour
|
||||
obj_updated_at = datetime.now() - timedelta(hours=1)
|
||||
cache_updated = max(
|
||||
datetime.fromtimestamp(cache_file.stat().st_mtime), cache_updated
|
||||
)
|
||||
if obj_updated_at <= cache_updated:
|
||||
return True, cached_obj
|
||||
return False, cached_obj
|
||||
|
Loading…
Reference in New Issue
Block a user