lru

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package go-lru implements an LRU cache. It is based on the LRU implementation in groupcache: https://github.com/golang/groupcache/tree/master/lru

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEvictionCallback

func WithEvictionCallback(onEvicted func(key string, value interface{})) func(c *Cache)

func WithExpiry

func WithExpiry(expiry time.Duration) func(c *Cache)

func WithoutSync

func WithoutSync() func(c *Cache)

Types

type Cache

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

func New

func New(size int, options ...func(*Cache)) *Cache

func (*Cache) Add

func (c *Cache) Add(key string, value interface{})

func (*Cache) Clear

func (c *Cache) Clear()

func (*Cache) Get

func (c *Cache) Get(key string) (value interface{}, ok bool)

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) Remove

func (c *Cache) Remove(key string)

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

func (*Cache) UpdateElement

func (c *Cache) UpdateElement(key string, value interface{})

Updates element's value without updating its "Least-Recently-Used" status

Jump to

Keyboard shortcuts

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