codec

package
v0.0.0-...-d283dcf Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package codec encodes cache values for the backends that store bytes rather than live objects.

It exists to keep encoding and decoding keyed on the same thing. The compact encoding dispatches on a value's dynamic type, taking a direct path for strings, byte slices and numbers, while decoding dispatches on the static type of its destination. The two agree whenever the cached type is concrete, and disagree exactly when it is an interface: a string stored through a Cache[any] would be written as raw bytes and then read back into an *any, where the compact form is not valid JSON and decoding fails with "unexpected value type". The exported Marshal and Unmarshal route both directions through the static T, which removes the disagreement at its source.

The encoding is process-local and carries no compatibility promise: it is not JSON for scalars, and nothing persists across a restart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal[T any](value T) ([]byte, error)

Marshal encodes value for storage in a byte-addressed cache.

func Unmarshal

func Unmarshal[T any](data []byte, value *T) error

Unmarshal decodes a value produced by Marshal for the same T.

Types

This section is empty.

Jump to

Keyboard shortcuts

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