lru

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package lru implements LRU cache algorithm .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRU

type LRU struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LRU is the base lru type.

func NewCache

func NewCache(storage storage.Storager, maxItems int) (*LRU, error)

NewCache returns new cache struct.

func (*LRU) Add

func (l *LRU) Add(item entities.CacheItem) (bool, error)

Add adds item into cache.

func (*LRU) Clear added in v0.1.0

func (l *LRU) Clear()

Clear clears all cache.

func (*LRU) Get

func (l *LRU) Get(hash string) (entities.CacheItem, bool, error)

Get got item from cache.

Jump to

Keyboard shortcuts

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