build: golang.org/x/build/internal/lru Index | Files

package lru

import "golang.org/x/build/internal/lru"

Package lru implements an LRU cache.

Index

Package Files

cache.go

type Cache Uses

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

Cache is an LRU cache, safe for concurrent access.

func New Uses

func New(maxEntries int) *Cache

New returns a new cache with the provided maximum items.

func (*Cache) Add Uses

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

Add adds the provided key and value to the cache, evicting an old item if necessary.

func (*Cache) Get Uses

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

Get fetches the key's value from the cache. The ok result will be true if the item was found.

func (*Cache) Len Uses

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) RemoveOldest Uses

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

RemoveOldest removes the oldest item in the cache and returns its key and value. If the cache is empty, the empty string and nil are returned.

Package lru imports 2 packages (graph) and is imported by 2 packages. Updated 2017-12-15. Refresh now. Tools for package owners.