codec

package
v0.0.0-...-d13d30b Latest Latest
Warning

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

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

Documentation

Overview

Package codec provides encode/decode interfaces for cache serialization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Marshal serializes v into bytes.
	Marshal(v any) ([]byte, error)
	// Unmarshal deserializes data into v (must be a pointer).
	Unmarshal(data []byte, v any) error
	// Name returns the codec identifier used for diagnostics.
	Name() string
}

Codec encodes and decodes values for cache storage.

var Default Codec = JSON{}

Default is the default codec instance.

type JSON

type JSON struct{}

JSON is the default codec using standard library encoding/json.

func (JSON) Marshal

func (JSON) Marshal(v any) ([]byte, error)

Marshal serializes v to JSON bytes.

func (JSON) Name

func (JSON) Name() string

Name returns "json".

func (JSON) Unmarshal

func (JSON) Unmarshal(data []byte, v any) error

Unmarshal deserializes JSON bytes into v.

type MsgPack

type MsgPack struct{}

MsgPack is a high-performance codec using MessagePack encoding.

func (MsgPack) Marshal

func (MsgPack) Marshal(v any) ([]byte, error)

Marshal serializes v to MessagePack bytes.

func (MsgPack) Name

func (MsgPack) Name() string

Name returns "msgpack".

func (MsgPack) Unmarshal

func (MsgPack) Unmarshal(data []byte, v any) error

Unmarshal deserializes MessagePack bytes into v.

Jump to

Keyboard shortcuts

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