lrucache

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRU

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

LRU provides a thread-safe LRU cache using hashicorp/golang-lru/v2.

func MustNew

func MustNew(maxEntries int) *LRU

MustNew creates a new LRU cache level or panics on error.

func New

func New(maxEntries int) (*LRU, error)

New creates a new LRU cache level. If maxEntries <= 0, a default capacity of 1000 is used.

func (*LRU) Add

func (l *LRU) Add(ctx context.Context, k entcache.Key, e *entcache.Entry, ttl time.Duration) error

Add adds the entry to the cache.

func (*LRU) Del

func (l *LRU) Del(ctx context.Context, k entcache.Key) error

Del deletes an entry from the cache.

func (*LRU) Get

func (l *LRU) Get(ctx context.Context, k entcache.Key) (*entcache.Entry, error)

Get gets an entry from the cache.

func (*LRU) LockOrWait added in v0.4.0

func (l *LRU) LockOrWait(ctx context.Context, k entcache.Key) (bool, func(context.Context) (*entcache.Entry, error), func(context.Context), error)

LockOrWait implements StampedeLocker interface using singleflight and wait channels.

Jump to

Keyboard shortcuts

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