ttllru

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Cacher
	TimeToLive time.Duration
	// contains filtered or unexported fields
}

Cache is a TTL LRU cache which caches items with a max time to live and with bounded length.

func (*Cache) Add

func (ttlCache *Cache) Add(key interface{}, val interface{}) bool

Add will add a value for a given key.

func (*Cache) Get

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

Get returns a value and a bool indicating the value was found for a given key.

func (*Cache) Peek added in v0.5.0

func (ttlCache *Cache) Peek(key interface{}) (value interface{}, expiration time.Time, ok bool)

Peek will fetch an item from the cache, but will not update the expiration time.

type Cacher added in v0.5.0

type Cacher interface {
	Get(key interface{}) (value interface{}, ok bool)
	Add(key interface{}, value interface{}) (evicted bool)
	Remove(key interface{}) (ok bool)
}

Cacher describes a basic cache.

type PeekingCacher added in v0.5.0

type PeekingCacher interface {
	Cacher
	Peek(key interface{}) (value interface{}, expiration time.Time, ok bool)
}

PeekingCacher describes a basic cache with the ability to peek.

func New

func New(size int, timeToLive time.Duration) (PeekingCacher, error)

New creates a new TTL LRU cache which caches items with a max time to live and with bounded length.

Directories

Path Synopsis
Package mock_ttllru is a generated GoMock package.
Package mock_ttllru is a generated GoMock package.

Jump to

Keyboard shortcuts

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