bytecache

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: BSD-3-Clause Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a high-performance sharded LRU byte cache. It provides O(1) lookups with minimal lock contention.

func New

func New(maxBytes int) *Cache

New creates a new byte cache with the given max size in bytes.

func (*Cache) Del

func (c *Cache) Del(key []byte)

Del removes a key from the cache.

func (*Cache) Get

func (c *Cache) Get(dst, key []byte) []byte

Get looks up a value by key, copying into dst if provided.

func (*Cache) GetBig

func (c *Cache) GetBig(dst, key []byte) []byte

GetBig is an alias for Get (compatibility).

func (*Cache) Has

func (c *Cache) Has(key []byte) bool

Has reports whether a key exists.

func (*Cache) HasGet

func (c *Cache) HasGet(dst, key []byte) ([]byte, bool)

HasGet returns the value and whether it exists.

func (*Cache) LoadFromFile

func (c *Cache) LoadFromFile(filePath string) error

LoadFromFile is a no-op for compatibility with fastcache API.

func (*Cache) Reset

func (c *Cache) Reset()

Reset clears all cached entries.

func (*Cache) SaveToFileConcurrent

func (c *Cache) SaveToFileConcurrent(filePath string, concurrency int) error

SaveToFileConcurrent is a no-op for compatibility with fastcache API.

func (*Cache) Set

func (c *Cache) Set(key, value []byte)

Set stores a key/value pair.

func (*Cache) SetBig

func (c *Cache) SetBig(key, value []byte)

SetBig is an alias for Set (compatibility).

func (*Cache) UpdateStats

func (c *Cache) UpdateStats(s *Stats)

UpdateStats populates the provided stats struct.

type Stats

type Stats struct {
	EntriesCount uint64
	BytesSize    uint64
	Collisions   uint64
	GetCalls     uint64
	SetCalls     uint64
	Misses       uint64
}

Stats contains cache performance metrics.

Jump to

Keyboard shortcuts

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