cache

package
v0.0.0-...-9a5932e Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2014 License: BSD-3-Clause Imports: 4 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 int64) *LRUCache

func (*LRUCache) Capacity

func (lru *LRUCache) Capacity() int64

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) Length

func (lru *LRUCache) Length() int64

func (*LRUCache) Oldest

func (lru *LRUCache) Oldest() (oldest time.Time)

func (*LRUCache) Set

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

func (*LRUCache) SetCapacity

func (lru *LRUCache) SetCapacity(capacity int64)

func (*LRUCache) SetIfAbsent

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

func (*LRUCache) Size

func (lru *LRUCache) Size() int64

func (*LRUCache) Stats

func (lru *LRUCache) Stats() (length, size, capacity int64, 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