lru

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

Repository implements the Repository cache

func New

func New(size, memory uint64, expiryTresHold time.Duration) *Repository

New constructs an Repository of the given size

func (*Repository) Clear

func (r *Repository) Clear() (err error)

Clear is used to completely clear the cache.

func (*Repository) Contains

func (r *Repository) Contains(key string) (ok bool)

Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.

func (*Repository) Delete

func (r *Repository) Delete(key string) (ok bool, err error)

Delete removes the provided key from the cache, returning if the key was contained.

func (*Repository) Get

func (r *Repository) Get(key string) (res *cache.Document, err error)

Get looks up a key's value from the cache.

func (*Repository) GetOldest

func (r *Repository) GetOldest() (res *cache.Document, err error)

GetOldest returns the oldest element

func (*Repository) Keys

func (r *Repository) Keys() (keys []string, err error)

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*Repository) Len

func (r *Repository) Len() (itemLen int64)

Len returns the number of items in the cache.

func (*Repository) Peek

func (r *Repository) Peek(key string) (res *cache.Document, err error)

Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.

func (*Repository) Set

func (r *Repository) Set(doc *cache.Document) (err error)

Set adds a value to the cache. Returns true if an eviction occurred.

Jump to

Keyboard shortcuts

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