MCPcopy Index your code
hub / github.com/psf/cachecontrol / _cache_set

Method _cache_set

cachecontrol/controller.py:294–322  ·  view source on GitHub ↗

Store the data in the cache.

(
        self,
        cache_url: str,
        request: PreparedRequest,
        response: HTTPResponse,
        body: bytes | None = None,
        expires_time: int | None = None,
    )

Source from the content-addressed store, hash-verified

292 return new_headers
293
294 def _cache_set(
295 self,
296 cache_url: str,
297 request: PreparedRequest,
298 response: HTTPResponse,
299 body: bytes | None = None,
300 expires_time: int | None = None,
301 ) -> None:
302 """
303 Store the data in the cache.
304 """
305 if isinstance(self.cache, SeparateBodyBaseCache):
306 # We pass in the body separately; just put a placeholder empty
307 # string in the metadata.
308 self.cache.set(
309 cache_url,
310 self.serializer.dumps(request, response, b""),
311 expires=expires_time,
312 )
313 # body is None can happen when, for example, we're only updating
314 # headers, as is the case in update_cached_response().
315 if body is not None:
316 self.cache.set_body(cache_url, body)
317 else:
318 self.cache.set(
319 cache_url,
320 self.serializer.dumps(request, response, body),
321 expires=expires_time,
322 )
323
324 def cache_response(
325 self,

Calls 3

setMethod · 0.45
dumpsMethod · 0.45
set_bodyMethod · 0.45