cache

package
v3.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package cache defines supported-adapter cache contracts for generated services.

Store is the minimal get/set/delete interface implemented by adapters such as cacheredis. ValidateKey and CloneBytes provide shared behavior for key validation and defensive byte-slice handling, and cachetest contains the adapter contract suite.

The package does not choose eviction, tenancy, serialization, or Redis key layout. Callers and adapters must keep cache keys service-scoped and avoid embedding secrets or raw personal data in keys.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("cache key is required")

ErrInvalidKey is returned when a cache key is empty after trimming space.

Functions

func CloneBytes

func CloneBytes(value []byte) []byte

CloneBytes returns a defensive copy of value.

func ValidateKey

func ValidateKey(key string) error

ValidateKey validates an application-owned cache key.

Types

type Store

type Store interface {
	Get(ctx context.Context, key string) ([]byte, bool, error)
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
}

Store is the minimal cache contract used by contrib adapters and generated services.

Directories

Path Synopsis
Package cachetest provides reusable cache adapter contract tests.
Package cachetest provides reusable cache adapter contract tests.

Jump to

Keyboard shortcuts

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