cache

package
v0.9.30-0...-9419e65 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0 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

View Source
var CacheMap map[string]*Item

CacheMap store UUID, size, type, atime and ctime in separate (sorted) table for access by fileReaper

View Source
var CacheMapLock = sync.RWMutex{}

CacheMapLock lock write access to the CacheMap

Functions

func Add

func Add(ID string, size int64)

Add an entry to the Cache for ID

func InitCacheReaper

func InitCacheReaper()

InitCacheReaper initializes the cache reaper if TTL is configured

func Initialize

func Initialize() (err error)

Initialize find all *.data files for nodes and populate cache only call if global --is-cache=true

func ParseTTL

func ParseTTL(ttlStr string) time.Duration

ParseTTL parses a TTL string like "24H", "7D", "30M" into a time.Duration

func Path2uuid

func Path2uuid(fpath string) string

Path2uuid extract uuid from path

func Remove

func Remove(ID string) (err error)

Remove an entry to the CacheMap and the file on disk

func Touch

func Touch(ID string)

Touch update cache LRU info

Types

type CacheCleanup

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

CacheCleanup handles periodic cleanup of expired cache items

var (
	CacheReaper *CacheCleanup
	TTLRegex    = regexp.MustCompile(`^(\d+)(M|H|D)$`)
)

func (*CacheCleanup) Handle

func (cr *CacheCleanup) Handle()

Handle runs the cache cleanup loop

type Item

type Item struct {
	UUID      string    `bson:"uuid" json:"uuid" `                   // e.g. node UUID
	Access    time.Time `bson:"last_accessed" json:"last_accessed" ` // e.g. access time
	Type      string    `bson:"type" json:"type"`
	Size      int64     `bson:"size" json:"size"  `        // e.g. size in bytes
	CreatedOn time.Time `bson:"url" json:"url" yaml:"URL"` // e.g. creation of local copy
}

Item information to manage file expiration on cache servers

Jump to

Keyboard shortcuts

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