package tlru

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

Index

Types

type TLRU

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

TLRU - Time aware Least Recently Used cache

func New

func New[V any](size int, ttl time.Duration, stale bool) *TLRU[V]

New TLRU cache

func (*TLRU[V]) Get

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

Get an item from cache

func (*TLRU[V]) Has

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

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

func (*TLRU[V]) Purge

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

Purge cache

func (*TLRU[V]) Remove

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

Remove an item from cache

func (*TLRU[V]) Set

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

Set an item to cache

Source Files

tlru.go

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

Tools for package owners.