cachecore

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOffsetCursor added in v0.2.0

func DecodeOffsetCursor(cursor string) (int, error)

func EncodeOffsetCursor added in v0.2.0

func EncodeOffsetCursor(offset int) string

func ListFilterTerm added in v0.2.0

func ListFilterTerm(opts ListPageOptions) string

func NormalizeListLimit added in v0.2.0

func NormalizeListLimit(limit int) int

Types

type BaseConfig

type BaseConfig struct {
	DefaultTTL    time.Duration
	Prefix        string
	Compression   CompressionCodec
	MaxValueBytes int
	EncryptionKey []byte
}

BaseConfig contains shared, backend-agnostic driver configuration.

type CacheEntry added in v0.2.0

type CacheEntry struct {
	Key       string
	SizeBytes int
	ExpiresAt *int64
}

func FilterAndSortEntries added in v0.2.0

func FilterAndSortEntries(entries []CacheEntry, filter string) []CacheEntry

type CompressionCodec

type CompressionCodec string

CompressionCodec represents a value compression algorithm.

const (
	CompressionNone   CompressionCodec = "none"
	CompressionGzip   CompressionCodec = "gzip"
	CompressionSnappy CompressionCodec = "snappy"
)

type Driver

type Driver string

Driver identifies cache backend.

const (
	DriverNull      Driver = "null"
	DriverFile      Driver = "file"
	DriverMemory    Driver = "memory"
	DriverMemcached Driver = "memcached"
	DriverDynamo    Driver = "dynamodb"
	DriverSQL       Driver = "sql"
	DriverRedis     Driver = "redis"
	DriverNATS      Driver = "nats"
)

type Inspector added in v0.2.0

type Inspector interface {
	Capabilities() InspectorCapabilities
	ListPage(ctx context.Context, opts ListPageOptions) (ListPageResult, error)
}

Inspector is an optional cache store extension for safe key browsing and metadata inspection.

Not every driver can support this efficiently or at all. Callers should check for support with a type assertion and respect Capabilities().

type InspectorCapabilities added in v0.2.0

type InspectorCapabilities struct {
	CanList   bool
	CanRead   bool
	CanDelete bool
	CanTTL    bool
}

type ListPageOptions added in v0.2.0

type ListPageOptions struct {
	// Query filters entries by matching any part of the cache key.
	// Prefix is retained as a backward-compatible alias.
	Query  string
	Prefix string
	Cursor string
	Limit  int
}

type ListPageResult added in v0.2.0

type ListPageResult struct {
	Entries    []CacheEntry
	NextCursor string
	HasMore    bool
}

func SliceEntries added in v0.2.0

func SliceEntries(entries []CacheEntry, offset int, limit int) ListPageResult

type Store

type Store interface {
	Driver() Driver
	Ready(ctx context.Context) error
	Get(ctx context.Context, key string) ([]byte, bool, error)
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
	Add(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error)
	Increment(ctx context.Context, key string, delta int64, ttl time.Duration) (int64, error)
	Decrement(ctx context.Context, key string, delta int64, ttl time.Duration) (int64, error)
	Delete(ctx context.Context, key string) error
	DeleteMany(ctx context.Context, keys ...string) error
	Flush(ctx context.Context) error
}

Store is the shared app cache contract.

Jump to

Keyboard shortcuts

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