lru

package
v0.0.0-...-d6e4ce5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 3 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 struct {
	// contains filtered or unexported fields
}

Cache represents safe for concurrent use Least Recently Used cache

func New

func New(capacity int) (*Cache, error)

New returns an initialized cache instance

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all saved records

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes the record associated with the specified key from the cache

func (*Cache) Get

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

Get returns (value, true) or (nil, false) for a given key

func (*Cache) LRU

func (c *Cache) LRU() (string, bool)

LRU returns (key, true) that was not touched for the longest time. Returns ("", false) if there are no keys in the cache. Does not "use" record i.e. returning record will remain untouched.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of records in the cache

func (*Cache) Put

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

Put inserts a new record into the cache

Jump to

Keyboard shortcuts

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