filecache

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 12 Imported by: 13

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