cache

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_LIMIT_SIZE = 2 * 1014 * 1024 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(limitSize uint64) *Cache

func (*Cache) Add

func (c *Cache) Add(key string, size int64)

func (*Cache) AddWithData

func (c *Cache) AddWithData(key, data string, size int64)

func (*Cache) Get

func (c *Cache) Get(key string) Item

func (*Cache) LoadCacheRecords

func (c *Cache) LoadCacheRecords(fpath string) error

func (*Cache) LoadCacheRecordsWithFiles

func (c *Cache) LoadCacheRecordsWithFiles(dir string) error

func (*Cache) RegisterSwapoutCallbacksCallbacks

func (c *Cache) RegisterSwapoutCallbacksCallbacks(handles ...func(Item))

func (Cache) RemoveItem

func (c Cache) RemoveItem(key string)

func (*Cache) SaveCacheRecords

func (c *Cache) SaveCacheRecords(fpath string) error

func (*Cache) Status

func (c *Cache) Status() Info

type Info

type Info struct {
	UsedSize   uint64
	CacheLimit uint64
	ItemNum    uint64
	Usage      float32
	HitRate    float32
}

type Item

type Item struct {
	Key       string
	Value     string
	Size      int64
	Freq      int
	AccessOn  time.Time
	Next, Pre *Item
}

Jump to

Keyboard shortcuts

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