memory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package memory provides an in-memory LRU cache with TTL expiration.

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 implements port.CachePort with LRU eviction

func NewMemoryCache

func NewMemoryCache(maxSize int, ttl time.Duration) *MemoryCache

NewMemoryCache creates a new in-memory cache with LRU eviction

func (*MemoryCache) Clear

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

Clear removes all entries from cache

func (*MemoryCache) Delete

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

Delete removes a key from cache

func (*MemoryCache) Get

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

Get retrieves a value from cache

func (*MemoryCache) Set

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

Set stores a value in cache

func (*MemoryCache) Stats

func (mc *MemoryCache) Stats() *port.CacheStats

Stats returns cache statistics

Jump to

Keyboard shortcuts

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