package lru

import "git.sr.ht/~xn/cache/v2/lru"

Index

Types

type LRU

type LRU[V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LRU - Least Recently Used cache

func New

func New[V any](size int) *LRU[V]

New LRU cache

func (*LRU[V]) Get

func (c *LRU[V]) Get(key string) V

Get an item from cache

func (*LRU[V]) Has

func (c *LRU[V]) Has(key string) bool

Has check if an item exists in cache, without useness update

func (*LRU[V]) Purge

func (c *LRU[V]) Purge()

Purge cache

func (*LRU[V]) Remove

func (c *LRU[V]) Remove(key string)

Remove an item from cache

func (*LRU[V]) Set

func (c *LRU[V]) Set(key string, value V)

Set an item to cache

Source Files

lru.go

Version
v2.1.0 (latest)
Published
Aug 29, 2022
Platform
linux/amd64
Imports
3 packages
Last checked
1 day ago

Tools for package owners.