fifocache

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShardInt

func ShardInt[T constraints.Integer](v T) uint8

Types

type Cache

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

Cache implements an in-memory cache with FIFO-based eviction it's mostly like the S3-fifo, only without the ghost queue part

func New

func New[K comparable, V any](
	capacity fscache.CapacityFunc,
	keyShardFunc func(K) uint8,
	postSet func(key K, value V),
	postGet func(key K, value V),
	postEvict func(key K, value V),
) *Cache[K, V]

func (*Cache[K, V]) Delete

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

func (*Cache[K, V]) Evict added in v1.2.3

func (c *Cache[K, V]) Evict(done chan int64)

func (*Cache[K, V]) Get

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

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, value V, size int64)

type DataCache added in v1.2.3

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

func NewDataCache added in v1.2.3

func NewDataCache(
	capacity fscache.CapacityFunc,
	postSet func(key fscache.CacheKey, value fscache.Data),
	postGet func(key fscache.CacheKey, value fscache.Data),
	postEvict func(key fscache.CacheKey, value fscache.Data),
) *DataCache

func (*DataCache) Available added in v1.2.3

func (d *DataCache) Available() int64

func (*DataCache) Capacity added in v1.2.3

func (d *DataCache) Capacity() int64

func (*DataCache) DeletePaths added in v1.2.3

func (d *DataCache) DeletePaths(ctx context.Context, paths []string)

func (*DataCache) EnsureNBytes added in v1.2.3

func (d *DataCache) EnsureNBytes(n int)

func (*DataCache) Evict added in v1.2.3

func (d *DataCache) Evict(ch chan int64)

func (*DataCache) Flush added in v1.2.3

func (d *DataCache) Flush()

func (*DataCache) Get added in v1.2.3

func (d *DataCache) Get(ctx context.Context, key query.CacheKey) (fscache.Data, bool)

func (*DataCache) Set added in v1.2.3

func (d *DataCache) Set(ctx context.Context, key query.CacheKey, value fscache.Data) error

func (*DataCache) Used added in v1.2.3

func (d *DataCache) Used() int64

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

Jump to

Keyboard shortcuts

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