kvcache

package
v2.1.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key interface {
	Hash() []byte
}

Key is the interface that every key in LRU Cache should implement.

type SimpleLRUCache

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

SimpleLRUCache is a simple least recently used cache, not thread-safe, use it carefully.

func NewSimpleLRUCache

func NewSimpleLRUCache(capacity uint) *SimpleLRUCache

NewSimpleLRUCache creates a SimpleLRUCache object, whose capacity is "capacity". NOTE: "capacity" should be a positive value.

func (*SimpleLRUCache) Get

func (l *SimpleLRUCache) Get(key Key) (value Value, ok bool)

Get tries to find the corresponding value according to the given key.

func (*SimpleLRUCache) Put

func (l *SimpleLRUCache) Put(key Key, value Value)

Put puts the (key, value) pair into the LRU Cache.

type Value

type Value interface {
}

Value is the interface that every value in LRU Cache should implement.

Jump to

Keyboard shortcuts

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