lru

package
Version: v0.0.0-...-868bdbc Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: AGPL-3.0 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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL