Pipeline#

SerializerPipeline

A pipeline of stages chained together to serialize and deserialize response objects.

Stage

Generic class to wrap serialization steps with consistent dumps() and loads() methods

class requests_cache.serializers.pipeline.SerializerPipeline(stages, is_binary=False)[source]#

Bases: object

A pipeline of stages chained together to serialize and deserialize response objects.

Parameters
  • stages (Sequence) – A sequence of Stage objects, or any objects with dumps() and loads() methods

  • is_binary (bool) – Indicates whether the serialized content is binary

dumps(value)[source]#
Return type

Union[str, bytes]

loads(value)[source]#
Return type

CachedResponse

class requests_cache.serializers.pipeline.Stage(obj=None, dumps='dumps', loads='loads')[source]#

Bases: object

Generic class to wrap serialization steps with consistent dumps() and loads() methods

Parameters
  • obj (Optional[Any]) – Serializer object or module, if applicable

  • dumps (Union[str, Callable]) – Serialization function, or name of method on obj

  • loads (Union[str, Callable]) – Deserialization function, or name of method on obj