MCPcopy Create free account
hub / github.com/FastLED/FastLED / load_cache

Function load_cache

ci/meson/example_metadata_cache.py:90–116  ·  view source on GitHub ↗

Load cached example metadata from build directory. Args: build_dir: Meson build directory (e.g., .build/meson-quick/) Returns: Cache dictionary with keys: hash, timestamp, metadata None if cache doesn't exist or is invalid

(build_dir: Path)

Source from the content-addressed store, hash-verified

88
89
90def load_cache(build_dir: Path) -> dict[str, str | float] | None:
91 """
92 Load cached example metadata from build directory.
93
94 Args:
95 build_dir: Meson build directory (e.g., .build/meson-quick/)
96
97 Returns:
98 Cache dictionary with keys: hash, timestamp, metadata
99 None if cache doesn't exist or is invalid
100 """
101 cache_file = build_dir / CACHE_FILENAME
102 if not cache_file.exists():
103 return None
104
105 try:
106 with open(cache_file, "r", encoding="utf-8") as f:
107 cache = json.load(f)
108
109 # Validate cache structure
110 required_keys = ["hash", "timestamp", "metadata"]
111 if not all(key in cache for key in required_keys):
112 return None
113
114 return cache
115 except (json.JSONDecodeError, OSError):
116 return None
117
118
119def save_cache(build_dir: Path, examples_hash: str, metadata: str) -> None:

Callers 1

mainFunction · 0.70

Calls 2

allFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected