inmemory

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache[T any](maxSize int) (cache.Cache[T], error)

NewCache creates a new in-memory cache with the specified TTL.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

Cache is a simple in-memory cache implementation using RWMutex and map

func (*Cache[T]) Delete

func (c *Cache[T]) Delete(_ context.Context, key string) error

Delete removes the specified key/value from the cache.

func (*Cache[T]) Get

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

Get returns the value associated with the key, or an error if not found.

func (*Cache[T]) Set

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

Set stores a value with the specified key.

Jump to

Keyboard shortcuts

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