cache

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSlice added in v1.3.0

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

func (ByteSlice) Get added in v1.3.0

func (s ByteSlice) Get(fn func() []byte) []byte

type Coster added in v1.3.10

type Coster interface {
	Cost() int
}

type CosterLRU added in v1.3.10

type CosterLRU[K comparable, V Coster] struct {
	// contains filtered or unexported fields
}

func MakeCosterLRU added in v1.3.10

func MakeCosterLRU[K comparable, V Coster](cap int) CosterLRU[K, V]

func NewCosterLRU added in v1.3.10

func NewCosterLRU[K comparable, V Coster](cap int) *CosterLRU[K, V]

func (*CosterLRU[K, V]) Get added in v1.3.10

func (c *CosterLRU[K, V]) Get(key K) (val V, ok bool)

func (*CosterLRU[K, V]) Put added in v1.3.10

func (c *CosterLRU[K, V]) Put(key K, value V)

type CosterRandom added in v1.3.13

type CosterRandom[K comparable, V Coster] struct {
	// contains filtered or unexported fields
}

CosterRandom is a key value cache with random eviction. The cache holds key values under cost cap and evicts random items if the cache holds cache items beyond the cost cap.

func MakeCosterRandom added in v1.3.13

func MakeCosterRandom[K comparable, V Coster](cap int, src rand.Source) CosterRandom[K, V]

MakeCosterRandom returns a new CosterRandom object.

func NewCosterRandom added in v1.3.13

func NewCosterRandom[K comparable, V Coster](cap int, src rand.Source) *CosterRandom[K, V]

func (*CosterRandom[K, V]) Get added in v1.3.13

func (c *CosterRandom[K, V]) Get(key K) (val V, ok bool)

func (*CosterRandom[K, V]) Put added in v1.3.13

func (c *CosterRandom[K, V]) Put(key K, value V)

type Create

type Create func([]byte) (interface{}, error)

type LRUCache

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

func NewLRUCache

func NewLRUCache(size int, create Create) *LRUCache

func (*LRUCache) Get

func (c *LRUCache) Get(key []byte) (interface{}, error)

func (*LRUCache) Len

func (c *LRUCache) Len() int

func (*LRUCache) Put

func (c *LRUCache) Put(key string, value interface{})

func (*LRUCache) Size

func (c *LRUCache) Size() int

type SimpleCache added in v0.9.7

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

func NewSimpleCache added in v0.9.7

func NewSimpleCache(cap int) *SimpleCache

func (*SimpleCache) Get added in v0.9.7

func (c *SimpleCache) Get(key []byte) interface{}

func (*SimpleCache) Put added in v0.9.7

func (c *SimpleCache) Put(key []byte, value interface{})

Jump to

Keyboard shortcuts

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