检查缓存文件是否在 TTL 期限内。
(group: str)
| 140 | |
| 141 | |
| 142 | def _cache_is_fresh(group: str) -> bool: |
| 143 | """检查缓存文件是否在 TTL 期限内。""" |
| 144 | meta_file = _meta_path(group) |
| 145 | if not meta_file.exists(): |
| 146 | return False |
| 147 | try: |
| 148 | meta = json.loads(meta_file.read_text(encoding="utf-8")) |
| 149 | age = time.time() - float(meta.get("fetched_at_unix", 0)) |
| 150 | return age < _CACHE_MAX_AGE_SECONDS |
| 151 | except Exception: |
| 152 | return False |
| 153 | |
| 154 | |
| 155 | def _parse_tle_text(text: str) -> List[TleEntry]: |
no test coverage detected