filecache

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 15 Imported by: 11 modules, 10 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 (
	ErrBadPath = errors.New("bad path")
	ErrIsDir   = errors.New("is directory")
)
View Source
var (
	ErrFileTooLarge    = errors.New("file too large for cache")
	ErrFileDisappeared = errors.New("file disappeared")
)

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(root string) (ret *Cache, err error)

func (*Cache) AsResourceProvider

func (me *Cache) AsResourceProvider() resource.Provider

func (*Cache) Info

func (me *Cache) Info() (ret CacheInfo)

func (*Cache) OpenFile

func (me *Cache) OpenFile(path string, flag int) (ret *File, err error)

func (*Cache) Remove

func (me *Cache) Remove(path string) error

func (*Cache) Rename

func (me *Cache) Rename(from, to string) (err error)

func (*Cache) SetCapacity

func (me *Cache) SetCapacity(capacity int64)

Setting a negative capacity means unlimited.

func (*Cache) Stat

func (me *Cache) Stat(path string) (os.FileInfo, error)

func (*Cache) StatFile

func (me *Cache) StatFile(path string) (os.FileInfo, error)

func (*Cache) TrimToCapacity

func (me *Cache) TrimToCapacity()

func (*Cache) WalkItems

func (me *Cache) WalkItems(cb func(ItemInfo))

Calls the function for every item known to be in the cache.

type CacheInfo

type CacheInfo struct {
	Capacity int64
	Filled   int64
	NumItems int
}

type File

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

func (*File) Close

func (me *File) Close() error

func (*File) Read

func (me *File) Read(b []byte) (n int, err error)

func (*File) ReadAt

func (me *File) ReadAt(b []byte, off int64) (n int, err error)

func (*File) Seek

func (me *File) Seek(offset int64, whence int) (ret int64, err error)

func (*File) Stat

func (me *File) Stat() (os.FileInfo, error)

func (*File) Write

func (me *File) Write(b []byte) (n int, err error)

func (*File) WriteAt

func (me *File) WriteAt(b []byte, off int64) (n int, err error)

type ItemInfo

type ItemInfo struct {
	Path     key
	Accessed time.Time
	Size     int64
}

type Policy

type Policy interface {
	Choose() policyItemKey
	Used(k policyItemKey, at time.Time)
	Forget(k policyItemKey)
	NumItems() int
}

Jump to

Keyboard shortcuts

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