memory

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memory implements a concurrent, in-process byte cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache evicts the oldest inserted entry when capacity is reached. Updating an entry keeps its insertion position. Expired entries are removed on Get.

func New

func New(capacity int) (*Cache, error)

New creates a cache with at most capacity entries. Zero means unlimited.

func (*Cache) Delete

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

func (*Cache) Get

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

func (*Cache) Put

func (c *Cache) Put(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