lru

package
v0.0.0-...-0f49ba3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[Key comparable, Value any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[Key comparable, Value any](maxEntries int) *Cache[Key, Value]

func (*Cache[Key, Value]) Add

func (c *Cache[Key, Value]) Add(key Key, value Value)

func (*Cache[Key, Value]) AddOrGet

func (c *Cache[Key, Value]) AddOrGet(key Key, value Value) (Value, bool)

When the key already exists, return its current value in lru and true otherwise insert the new key-value and return nil and false

func (*Cache[Key, Value]) Clear

func (c *Cache[Key, Value]) Clear()

func (*Cache[Key, Value]) Contain

func (c *Cache[Key, Value]) Contain(key Key) bool

Contain will check if a key is in the cache, but not modify the list

func (*Cache[Key, Value]) Get

func (c *Cache[Key, Value]) Get(key Key) (value Value, ok bool)

func (*Cache[Key, Value]) Keys

func (c *Cache[Key, Value]) Keys() []Key

Keys returns a slice of all keys, from oldest to newest

func (*Cache[Key, Value]) Len

func (c *Cache[Key, Value]) Len() int

func (*Cache[Key, Value]) Peek

func (c *Cache[Key, Value]) Peek(key Key) (value Value, ok bool)

Peek will return the key value but not modify the list

func (*Cache[Key, Value]) Remove

func (c *Cache[Key, Value]) Remove(key Key)

func (*Cache[Key, Value]) Values

func (c *Cache[Key, Value]) Values() []Value

Values returns a slice of all values, from oldest to newest

type Cache32

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

func NewCache32

func NewCache32(maxEntries int) *Cache32

func (*Cache32) Add

func (c *Cache32) Add(key uint32, value interface{})

func (*Cache32) Clear

func (c *Cache32) Clear()

func (*Cache32) Contain

func (c *Cache32) Contain(key uint32) bool

Contain will check if a key is in the cache, but not modify the list

func (*Cache32) Get

func (c *Cache32) Get(key uint32) (value interface{}, ok bool)

func (*Cache32) Keys

func (c *Cache32) Keys() []uint32

Keys returns a slice of all keys, from oldest to newest

func (*Cache32) Len

func (c *Cache32) Len() int

func (*Cache32) Peek

func (c *Cache32) Peek(key uint32) (value interface{}, ok bool)

Peek will return the key value but not modify the list

func (*Cache32) Remove

func (c *Cache32) Remove(key uint32)

func (*Cache32) Values

func (c *Cache32) Values() []interface{}

Values returns a slice of all values, from oldest to newest

type Cache64

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

func NewCache64

func NewCache64(maxEntries int) *Cache64

func (*Cache64) Add

func (c *Cache64) Add(key uint64, value interface{})

func (*Cache64) Clear

func (c *Cache64) Clear()

func (*Cache64) Contain

func (c *Cache64) Contain(key uint64) bool

Contain will check if a key is in the cache, but not modify the list

func (*Cache64) Get

func (c *Cache64) Get(key uint64) (value interface{}, ok bool)

func (*Cache64) Keys

func (c *Cache64) Keys() []uint64

Keys returns a slice of all keys, from oldest to newest

func (*Cache64) Len

func (c *Cache64) Len() int

func (*Cache64) Peek

func (c *Cache64) Peek(key uint64) (value interface{}, ok bool)

Peek will return the key value but not modify the list

func (*Cache64) Remove

func (c *Cache64) Remove(key uint64)

func (*Cache64) Values

func (c *Cache64) Values() []interface{}

Values returns a slice of all values, from oldest to newest

Jump to

Keyboard shortcuts

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