lru

package
v0.0.0-...-6608488 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2013 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package lru implements an LRU cache.

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 an LRU cache, safe for concurrent access.

func New

func New(maxEntries int) *Cache

New returns a new cache with the provided maximum items.

func (*Cache) Add

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

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

func (*Cache) Get

func (c *Cache) Get(key string) (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

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item in the cache.

Jump to

Keyboard shortcuts

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