Skip to main content

Module codec

Module codec 

Source
Expand description

Serialization of cached entries, and the on-the-wire format used by the shared backends.

Two layers are involved, and they are deliberately separate:

  • A CacheCodec turns a CacheEntry into bytes and back. The default is PostcardCodec. A codec knows nothing about expiry.
  • The envelope wraps that payload in a 21-byte versioned header that carries the magic, the format version, the codec id, and the entry’s expiry and stale-until timestamps.

See envelope for the byte layout. Custom codecs only implement CacheCodec; the envelope is applied by the backend.

Modules§

envelope
The versioned envelope wrapped around every value written to a shared backend by 0.6.0 and later.
legacy
Reader for cache entries written by tower-http-cache 0.5.x.

Structs§

PostcardCodec
Default CacheCodec implementation, backed by postcard.

Traits§

CacheCodec
Trait representing a serialization strategy for cached entries.

Type Aliases§

BincodeCodecDeprecated
Former name of PostcardCodec.