MCPcopy Create free account
hub / github.com/psf/cachecontrol / SeparateBodyFileCache

Class SeparateBodyFileCache

cachecontrol/caches/file_cache.py:117–136  ·  view source on GitHub ↗

Memory-efficient FileCache: body is stored in a separate file, reducing peak memory usage.

Source from the content-addressed store, hash-verified

115
116
117class SeparateBodyFileCache(_FileCacheMixin, SeparateBodyBaseCache):
118 """
119 Memory-efficient FileCache: body is stored in a separate file, reducing
120 peak memory usage.
121 """
122
123 def get_body(self, key: str) -> IO[bytes] | None:
124 name = self._fn(key) + ".body"
125 try:
126 return open(name, "rb")
127 except FileNotFoundError:
128 return None
129
130 def set_body(self, key: str, body: bytes) -> None:
131 name = self._fn(key) + ".body"
132 self._write(name, body)
133
134 def delete(self, key: str) -> None:
135 self._delete(key, "")
136 self._delete(key, ".body")
137
138
139def url_to_file_path(url: str, filecache: FileCache) -> str:

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…