lru

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2018 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 Cache

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

Cache is a simple concurrent-safe cache with a least-recently-used (LRU) eviction policy.

func NewCache

func NewCache(limit int) *Cache

NewCache instantiates a new concurrent-safe LRU cache.

func (*Cache) Get

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

Get returns a cached value for a key, and initializes it otherwise should it not exist.

Jump to

Keyboard shortcuts

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