lruCache

package
v0.0.0-...-682d07f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 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 is a LRU cache where some elements are not subject to the LRU removal strategy. This cache is safe for concurrent use.

func New

func New() *Cache

New returns a freshly created cache with all its internal structures initialized

func (*Cache) Get

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

Get returns if the key is present the value associated with it from the map and true. Otherwise the value type's zero value and false is returned

func (*Cache) GetAll

func (c *Cache) GetAll() []interface{}

GetAll returns all contained values. It does not affect lru list order.

func (*Cache) GetLeastRecentlyUsed

func (c *Cache) GetLeastRecentlyUsed() (string, interface{})

GetLeastRecentlyUsed returns the least recently used key value pair. It does not update the recentness of the element

func (*Cache) GetOrAdd

func (c *Cache) GetOrAdd(key string, value interface{}, isInternal bool) (interface{}, bool)

GetOrAdd only inserts the key value pair to Cache if there has not yet been a mapping for key. It first returns the already existing value associated with the key or otherwise the new value. The second return value is a boolean value which is true if the mapping has not yet been present.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of elements in the cache

func (*Cache) Remove

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

Remove deletes the key value pair from the map. It returns the value and true if an element was deleted. Otherwise the value and false.

Jump to

Keyboard shortcuts

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