cache

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 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 cache provides byte-oriented cache implementations. Consumers define their own interfaces; this package depends on neither MCP nor skill storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryCache

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

MemoryCache stores at most 256 keys, evicting the earliest-expiring entry. Use one shared instance to share invalidation between stores in one process.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Delete

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

func (*MemoryCache) Get

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

func (*MemoryCache) Set

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

type RedisCache

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

RedisCache adapts an application-owned Redis client for consumer-owned cache interfaces. Use the same prefix on replicas sharing a backing store; use distinct prefixes for unrelated deployments. The caller closes the client.

func NewRedisCache

func NewRedisCache(client redis.Cmdable, prefix string) (*RedisCache, error)

func (*RedisCache) Delete

func (c *RedisCache) Delete(ctx context.Context, key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, key string) ([]byte, bool, error)

func (*RedisCache) Set

func (c *RedisCache) Set(ctx 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