MCPcopy Create free account
hub / github.com/Tong89/smartNode / _write_cache

Function _write_cache

backend/physics/tle_source.py:114–131  ·  view source on GitHub ↗

将拉取的 TLE 原始文本写入缓存文件并更新元数据。

(group: str, raw_text: str)

Source from the content-addressed store, hash-verified

112
113
114def _write_cache(group: str, raw_text: str) -> None:
115 """将拉取的 TLE 原始文本写入缓存文件并更新元数据。"""
116 _ensure_cache_dir()
117 cache_file = _cache_path(group)
118 meta_file = _meta_path(group)
119
120 cache_file.write_text(raw_text, encoding="utf-8")
121
122 entries = _parse_tle_text(raw_text)
123 meta = {
124 "group": group,
125 "fetched_at": datetime.now(timezone.utc).isoformat(),
126 "fetched_at_unix": time.time(),
127 "entry_count": len(entries),
128 "source": "celestrak",
129 }
130 meta_file.write_text(json.dumps(meta, ensure_ascii=False, indent=2), encoding="utf-8")
131 logger.info("TLE 缓存已更新: group=%s, entries=%d", group, len(entries))
132
133
134def _read_cache(group: str) -> Optional[str]:

Callers 2

fetch_groupFunction · 0.85
fetch_by_catnrFunction · 0.85

Calls 4

_ensure_cache_dirFunction · 0.85
_cache_pathFunction · 0.85
_meta_pathFunction · 0.85
_parse_tle_textFunction · 0.85

Tested by

no test coverage detected