cache2go

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: BSD-3-Clause Imports: 3 Imported by: 6

README

cache2go Build Status

Golang simple object caching library with LRU and expiration capabilities. The items are evicted if the capacity is exceeded or if they expire.

See the test file for wroking examples.

API docs here.

NOTE: For those looking for the alternate implementation please check the muesli branch or better track the muesli fork which is actively mentained (https://github.com/muesli/cache2go).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is an LRU cache.

func New

func New(maxEntries int, expire time.Duration) *Cache

New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Remove removes the provided key from the cache.

func (*Cache) Flush

func (c *Cache) Flush()

empties the whole cache

func (*Cache) Get

func (c *Cache) Get(key string) (value interface{}, ok bool)

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

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

Add adds a value to the cache

Jump to

Keyboard shortcuts

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