lru

package
v0.0.0-...-ca65d48 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lru implements LRU cache.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStopped is returned when the cache is stopped or not initialized.
	ErrStopped = fmt.Errorf("lru: stopped or not initialized")

	// ErrNamespaceNotFound is returned when the namespace is not found.
	ErrNamespaceNotFound = fmt.Errorf("lru: namespace not found")

	// ErrKeyNotFound is returned when the key is not found.
	ErrKeyNotFound = fmt.Errorf("lru: key not found")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// CreateNamespace creates a new bucket in cache.
	CreateNamespace(namespace string)

	// Put writes a key-value pair. If the namespace is not found, create one.
	Put(namespace string, key, value interface{}) error

	// Get returns the value, or 'ErrKeyNotFound'. If the namespace is not found, returns 'ErrNamespaceNotFound'.
	Get(namespace string, key interface{}) (interface{}, error)
}

Cache defines LRU cache store.

func NewInMemory

func NewInMemory(size int) Cache

NewInMemory returns a new in-memory LRU cache.

Jump to

Keyboard shortcuts

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