cache

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cache defines a tiny adapter boundary for optional caching layers.

Package cache defines a minimal cache interface for GoMyAdmin adapters.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("cache: key not found")

Functions

This section is empty.

Types

type Cache

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

Cache is the minimal contract GoMyAdmin adapters need from Redis, Memcached, in-memory caches, or an existing application cache.

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

MemoryCache is a small concurrency-safe cache for tests and single-process development. Production deployments should prefer Redis, Memcached, or a shared application cache.

func NewMemory

func NewMemory() *MemoryCache

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(_ context.Context, key string) error

func (*MemoryCache) Get

func (c *MemoryCache) Get(_ context.Context, key string) ([]byte, error)

func (*MemoryCache) Set

func (c *MemoryCache) Set(_ context.Context, key string, value []byte, ttl time.Duration) error

Jump to

Keyboard shortcuts

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