mru

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

This package implements a synchronized MRU (most recently used) map. Its a map that will hold at most cap key/value pairs and will evict entries if: 1) adding an element would exceed cap, in this case the oldest existing element is removed to make space for a new one. 2) an element's age exceeds maxage, the check is done when adding elements. Age is defined as the duration between now and the time the element was last accessed (added or looked up).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

func NewMap

func NewMap(cap int, maxage time.Duration) *Map

func (*Map) Add

func (m *Map) Add(k interface{}, v interface{})

func (*Map) Lookup

func (m *Map) Lookup(k interface{}) (v interface{}, ok bool)

func (*Map) LookupAndTouch

func (m *Map) LookupAndTouch(k interface{}) (v interface{}, ok bool)

Jump to

Keyboard shortcuts

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