cache

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 2 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 struct {
	Cap uint64
	// contains filtered or unexported fields
}

LRU non-thread safe fixed size LRU cache

func NewLRUCache

func NewLRUCache(capacity uint64) *LRU

NewLRUCache returns a new non-concurrent-safe LRU cache with input capacity

func (*LRU) Add

func (l *LRU) Add(key, value interface{})

Add adds a value to the cache

func (*LRU) Clear

func (l *LRU) Clear()

Clear is used to completely clear the cache.

func (*LRU) Contains

func (l *LRU) Contains(key interface{}) (f bool)

Contains check if key is in cache this does not update LRU

func (*LRU) Get

func (l *LRU) Get(key interface{}) interface{}

Get returns keys value from cache if found

func (*LRU) Len

func (l *LRU) Len() uint64

Len returns length of l

func (*LRU) Remove

func (l *LRU) Remove(key interface{}) bool

Remove removes key from the cache, if the key was removed.

type LRUCache

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

LRUCache thread safe fixed size LRU cache

func New

func New(capacity uint64) *LRUCache

New returns a new concurrent-safe LRU cache with input capacity

func (*LRUCache) Add

func (l *LRUCache) Add(k, v interface{})

Add new entry to Cache return true if entry removed

func (*LRUCache) Clear

func (l *LRUCache) Clear()

Clear is used to clear the cache.

func (*LRUCache) Contains

func (l *LRUCache) Contains(key interface{}) bool

Contains checks if cache contains key

func (*LRUCache) ContainsOrAdd

func (l *LRUCache) ContainsOrAdd(key, value interface{}) bool

ContainsOrAdd checks if cache contains key if not adds to cache

func (*LRUCache) Get

func (l *LRUCache) Get(key interface{}) (value interface{})

Get looks up a key's value from the cache.

func (*LRUCache) Len

func (l *LRUCache) Len() uint64

Len returns the number of items in the cache.

func (*LRUCache) Remove

func (l *LRUCache) Remove(key interface{}) bool

Remove entry from cache

Jump to

Keyboard shortcuts

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