cachex

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 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 Cacher

type Cacher[K, V any] interface {
	Set(key K, value V)
	Get(key K) (value V, ok bool)
	Delete(key K)
	Clear()
	Len() int
}

type CacherMock

type CacherMock[K interface{}, V interface{}] struct {
	mock.Mock
}

CacherMock is an autogenerated mock type for the Cacher type

func NewCacherMock

func NewCacherMock[K interface{}, V interface{}](t mockConstructorTestingTNewCacherMock) *CacherMock[K, V]

NewCacherMock creates a new instance of CacherMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*CacherMock[K, V]) Clear

func (_m *CacherMock[K, V]) Clear()

Clear provides a mock function with given fields:

func (*CacherMock[K, V]) Delete

func (_m *CacherMock[K, V]) Delete(key K)

Delete provides a mock function with given fields: key

func (*CacherMock[K, V]) Get

func (_m *CacherMock[K, V]) Get(key K) (V, bool)

Get provides a mock function with given fields: key

func (*CacherMock[K, V]) Len

func (_m *CacherMock[K, V]) Len() int

Len provides a mock function with given fields:

func (*CacherMock[K, V]) Set

func (_m *CacherMock[K, V]) Set(key K, value V)

Set provides a mock function with given fields: key, value

type LRUCache

type LRUCache[K, V any] struct {
	// contains filtered or unexported fields
}

LRUCache is Least Recently Used (LRU) cache.

func NewLRUCache

func NewLRUCache[K, V any](capacity int) *LRUCache[K, V]

func (*LRUCache[K, V]) Clear

func (c *LRUCache[K, V]) Clear()

func (*LRUCache[K, V]) Delete

func (c *LRUCache[K, V]) Delete(key K)

func (*LRUCache[K, V]) Get

func (c *LRUCache[K, V]) Get(key K) (value V, ok bool)

func (*LRUCache[K, V]) Len

func (c *LRUCache[K, V]) Len() int

func (*LRUCache[K, V]) Set

func (c *LRUCache[K, V]) Set(key K, value V)

type LRUCacheExpiry added in v0.2.0

type LRUCacheExpiry[K, V any] struct {
	LRUCache[K, ValueWithExpiry[V]]
	// contains filtered or unexported fields
}

LRUCacheExpiry is Least Recently Used (LRU) cache.

func NewLRUCacheExpiry added in v0.2.0

func NewLRUCacheExpiry[K, V any](capacity int, options Options) *LRUCacheExpiry[K, V]

func (*LRUCacheExpiry[K, V]) Get added in v0.2.0

func (c *LRUCacheExpiry[K, V]) Get(key K) (value V, ok bool)

func (*LRUCacheExpiry[K, V]) Set added in v0.2.0

func (c *LRUCacheExpiry[K, V]) Set(key K, value V)

type Options added in v0.2.0

type Options struct {
	MaxTimeToLive time.Duration
}

type ValueWithExpiry added in v0.2.0

type ValueWithExpiry[V any] struct {
	Value     V
	KeyExpiry time.Time
}

Jump to

Keyboard shortcuts

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