cache

package
v0.0.0-...-66deda4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2017 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

The implementation borrows heavily from SmallLRUCache (originally by Nathan Schrenk). The object maintains a doubly-linked list of elements in the When an element is accessed it is promoted to the head of the list, and when space is needed the element at the tail of the list (the least recently used element) is evicted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Key   string
	Value Value
}

type LRUCache

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

func NewLRUCache

func NewLRUCache(capacity uint64) *LRUCache

func (*LRUCache) Clear

func (lru *LRUCache) Clear()

func (*LRUCache) Delete

func (lru *LRUCache) Delete(key string) bool

func (*LRUCache) Get

func (lru *LRUCache) Get(key string) (v Value, ok bool)

func (*LRUCache) Items

func (lru *LRUCache) Items() []Item

func (*LRUCache) Keys

func (lru *LRUCache) Keys() []string

func (*LRUCache) LoadItems

func (lru *LRUCache) LoadItems(r io.Reader) error

func (*LRUCache) LoadItemsFromFile

func (lru *LRUCache) LoadItemsFromFile(path string) error

func (*LRUCache) SaveItems

func (lru *LRUCache) SaveItems(w io.Writer) error

func (*LRUCache) SaveItemsToFile

func (lru *LRUCache) SaveItemsToFile(path string) error

func (*LRUCache) Set

func (lru *LRUCache) Set(key string, value Value)

func (*LRUCache) SetCapacity

func (lru *LRUCache) SetCapacity(capacity uint64)

func (*LRUCache) SetIfAbsent

func (lru *LRUCache) SetIfAbsent(key string, value Value)

func (*LRUCache) Stats

func (lru *LRUCache) Stats() (length, size, capacity uint64, oldest time.Time)

func (*LRUCache) StatsJSON

func (lru *LRUCache) StatsJSON() string

type Value

type Value interface {
	Size() int
}

Values that go into LRUCache need to satisfy this interface.

Jump to

Keyboard shortcuts

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