wire

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wire implements the persistent entry envelope and the invalidation message format shared by the serialized backends. Both formats are versioned; readers must understand a version before any writer emits it.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidEnvelope = errors.New("cache: invalid entry envelope")

ErrInvalidEnvelope reports a truncated envelope or an unknown version.

Functions

func DecodeInvalidation

func DecodeInvalidation[K comparable](encoded []byte, codec cache.Codec[K]) (cache.InvalidationEvent[K], error)

DecodeInvalidation decodes a remote invalidation event.

func EncodeInvalidation

func EncodeInvalidation[K comparable](event cache.InvalidationEvent[K], codec cache.Codec[K]) ([]byte, error)

EncodeInvalidation encodes an invalidation event for a remote transport.

func Namespace

func Namespace(namespace string) [sha256.Size]byte

Namespace returns the SHA-256 digest of namespace.

Types

type Encoder

type Encoder[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Encoder canonicalizes keys and serializes cache entries.

func New

func New[K comparable, V any](keyCodec cache.Codec[K], valueCodec cache.Codec[V]) *Encoder[K, V]

New returns an encoder for the given key and value codecs.

func (*Encoder[K, V]) Decode

func (e *Encoder[K, V]) Decode(envelope []byte) (cache.Entry[V], uint64, error)

Decode parses a version-1 or version-2 envelope.

func (*Encoder[K, V]) Encode

func (e *Encoder[K, V]) Encode(entry cache.Entry[V], generation uint64) ([]byte, error)

Encode serializes entry and the namespace generation as a version-2 envelope: version byte, generation (uint64), expiry seconds (int64) and nanoseconds (uint32), flags byte, then the encoded value.

func (*Encoder[K, V]) Key

func (e *Encoder[K, V]) Key(key K) ([sha256.Size]byte, error)

Key returns the SHA-256 digest of the encoded key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL