memory

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxSize         int64
	MaxKeys         int
	DefaultTTL      time.Duration
	CleanupInterval time.Duration
	KeyPrefix       string
	Namespace       string
}

Config holds memory cache specific configuration

type MemoryCache

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

MemoryCache implements an in-memory cache

func New

func New(cfg Config) (*MemoryCache, error)

New creates a new memory cache instance

func (*MemoryCache) Clear

func (mc *MemoryCache) Clear(ctx context.Context) error

Clear removes all keys

func (*MemoryCache) Close

func (mc *MemoryCache) Close() error

Close closes the cache

func (*MemoryCache) Delete

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

Delete removes a key

func (*MemoryCache) Exists

func (mc *MemoryCache) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists

func (*MemoryCache) Get

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

Get retrieves a value by key

func (*MemoryCache) Ping

func (mc *MemoryCache) Ping(ctx context.Context) error

Ping checks if cache is operational

func (*MemoryCache) Set

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

Set stores a value with optional TTL

func (*MemoryCache) Stats

func (mc *MemoryCache) Stats() map[string]interface{}

Stats returns cache statistics

Jump to

Keyboard shortcuts

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