cache

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 4 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[K comparable, V any] struct {
	// contains filtered or unexported fields
}

LRU implements the dataloader.Cache interface

func NewLRU

func NewLRU[K comparable, V any](size int, ttl time.Duration) *LRU[K, V]

NewLRU creates a new LRU cache size is the size of the cache. If size is 0, the cache has no limit

func (*LRU[K, V]) Clear

func (c *LRU[K, V]) Clear()

Clear clears the cache

func (*LRU[K, V]) Delete

func (c *LRU[K, V]) Delete(_ context.Context, key K) bool

Delete deletes an item in the cache

func (*LRU[K, V]) Get

func (c *LRU[K, V]) Get(_ context.Context, key K) (dataloader.Thunk[V], bool)

Get gets an item from the cache

func (*LRU[K, V]) Set

func (c *LRU[K, V]) Set(_ context.Context, key K, value dataloader.Thunk[V])

Set sets an item in the LRU

Jump to

Keyboard shortcuts

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