cache

package
v3.2.257 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadyGate

type ReadyGate struct {
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

ReadyGate manages blocking cache consumers until the requested data is available.

func NewReadyGate

func NewReadyGate() *ReadyGate

func (*ReadyGate) Add

func (gate *ReadyGate) Add()

func (*ReadyGate) Available

func (gate *ReadyGate) Available() int64

func (*ReadyGate) Done

func (gate *ReadyGate) Done()

func (*ReadyGate) Finish

func (gate *ReadyGate) Finish(err error, total int64)

func (*ReadyGate) SetAvailable

func (gate *ReadyGate) SetAvailable(x int64)

func (*ReadyGate) SetCancel

func (gate *ReadyGate) SetCancel(cancel context.CancelFunc)

func (*ReadyGate) WaitFor

func (gate *ReadyGate) WaitFor(end int64) error

type Stats

type Stats struct {
	// CapacityBytes is the maximum size of the cache in bytes. 0 means unbounded.
	//
	// This is set when the cache is created and does not change.
	CapacityBytes int64

	// CapacityBytesRemaining is the remaining size of the cache in bytes.
	//
	// This is calculated as CapacityBytes - SizeBytes.
	CapacityBytesRemaining int64

	// MaxFileCount is the maximum number of files in the cache. 0 means unbounded.
	//
	// This is set when the cache is created and does not change.
	MaxFileCount int64

	// FileCountRemaining is the remaining number of files that can be stored in the cache.
	//
	// This is calculated as MaxFileCount - FileCount.
	FileCountRemaining int64

	// FileCount represents the number of files in the cache.
	FileCount atomic.Int64

	// ReadBytes is the total number of bytes read from the cache.
	// This is incremented on each successful Read call.
	ReadBytes atomic.Int64

	// ReadCount is the total number of Read calls.
	ReadCount atomic.Int64

	// SizeBytes is the total size of all files in the cache.
	SizeBytes atomic.Int64

	// WriteBytes is the total number of bytes written to the cache.
	// This is incremented on each successful Write call.
	WriteBytes atomic.Int64

	// WriteCount is the total number of Write calls.
	WriteCount atomic.Int64

	// LoadDuration is the time taken to refresh in-memory cache statistics from disk during the most recent load.
	LoadDuration time.Duration

	// LruCount is the number of items in the LRU cache.
	LruCount int
}

Stats maintains statistics about cache usage.

func (*Stats) MarshalJSON

func (st *Stats) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Stats. It ensures CapacityRemaining is calculated as Capacity - SizeBytes.

func (*Stats) ResetCounters

func (st *Stats) ResetCounters()

ResetCounters sets "counter" type stats to zero.

It does not reset Capacity, CapacityRemaining, FileCount, or SizeBytes.

Directories

Path Synopsis
Package disk implements a disk-based cache for file data.
Package disk implements a disk-based cache for file data.

Jump to

Keyboard shortcuts

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