pilosa: github.com/pilosa/pilosa/lru Index | Files

package lru

import "github.com/pilosa/pilosa/lru"

Package lru implements an LRU cache.

Index

Package Files

lru.go

type Cache Uses

type Cache struct {

    // OnEvicted optionally specifies a callback function to be
    // executed when an entry is purged from the cache.
    OnEvicted func(key Key, value interface{})
    // contains filtered or unexported fields
}

Cache is an LRU cache. It is not safe for concurrent access.

func New Uses

func New(maxEntries int) *Cache

New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.

func (*Cache) Add Uses

func (c *Cache) Add(key Key, value interface{})

Add adds a value to the cache.

func (*Cache) Get Uses

func (c *Cache) Get(key Key) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len Uses

func (c *Cache) Len() int

Len returns the number of items in the cache.

type Key Uses

type Key interface{}

A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators

Package lru imports 1 packages (graph) and is imported by 2 packages. Updated 2019-05-13. Refresh now. Tools for package owners.