Skip to content

No-operation

cachetory.serializers.NoopSerializer

No-operation serializer: just forwards the value to and from backend.

Tip

This serializer is especially useful with the dummy or memory backend since they do not really need any serializer and having a one would only waste CPU cycles.

Source code in cachetory/serializers/noop.py
class NoopSerializer(Serializer[ValueT, ValueT], Generic[ValueT]):
    """
    No-operation serializer: just forwards the value to and from backend.

    Tip:
        This serializer is especially useful with the dummy or memory backend since they do not
        really need any serializer and having a one would only waste CPU cycles.
    """

    @classmethod
    def from_url(cls, url: str) -> NoopSerializer[ValueT]:
        """
        Construct serializer from the URL.

        # Supported schema's

        - `noop://`
        - `null://`
        """
        return NoopSerializer[ValueT]()

    def serialize(self, value: ValueT) -> ValueT:
        return value

    def deserialize(self, data: ValueT) -> ValueT:
        return data

from_url classmethod

from_url(url: str) -> NoopSerializer[ValueT]

Construct serializer from the URL.

Supported schema's

  • noop://
  • null://
Source code in cachetory/serializers/noop.py
@classmethod
def from_url(cls, url: str) -> NoopSerializer[ValueT]:
    """
    Construct serializer from the URL.

    # Supported schema's

    - `noop://`
    - `null://`
    """
    return NoopSerializer[ValueT]()