cache

package
v0.0.0-...-778c101 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirPathTimeout  = time.Second * 10
	DefaultDirPathMaxCount = 100
	DefaultNegPathTimeout  = time.Second * 3
	DefaultNegPathMaxCount = 100
	DefaultLoopPeriod      = time.Second * 10
	DefaultUploadDelay     = DefaultLoopPeriod
	DefaultEvictDelay      = DefaultLoopPeriod * 3
)
View Source
const (
	OpenIfExists = 0
	Open         = 1
	Activate     = 2
)
View Source
const Version = 1 // bump version when database format changes

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func OpenCache

func OpenCache(
	path string, storage objio.ObjectStorage, config *Config, flag int) (
	self *Cache, err error)

func (*Cache) Chtime

func (self *Cache) Chtime(ino uint64, mtime time.Time) (err error)

func (*Cache) Close

func (self *Cache) Close(ino uint64) (err error)

func (*Cache) CloseCache

func (self *Cache) CloseCache() (err error)

func (*Cache) ListCache

func (self *Cache) ListCache() (paths []string)

func (*Cache) Make

func (self *Cache) Make(ino uint64, dir bool) (err error)

func (*Cache) Open

func (self *Cache) Open(path string) (ino uint64, err error)

func (*Cache) ReadAt

func (self *Cache) ReadAt(ino uint64, buf []byte, off int64) (n int, err error)

func (*Cache) Readdir

func (self *Cache) Readdir(ino uint64, maxcount int) (infos []objio.ObjectInfo, err error)

func (*Cache) Remove

func (self *Cache) Remove(ino uint64, dir bool) (err error)

func (*Cache) Rename

func (self *Cache) Rename(ino uint64, newpath string) (err error)

func (*Cache) ResetCache

func (self *Cache) ResetCache(progress func(path string)) (err error)

func (*Cache) Stat

func (self *Cache) Stat(ino uint64) (info objio.ObjectInfo, err error)

func (*Cache) Statfs

func (self *Cache) Statfs() (info objio.StorageInfo, err error)

func (*Cache) Storage

func (self *Cache) Storage() objio.ObjectStorage

func (*Cache) Sync

func (self *Cache) Sync(ino uint64) (err error)

func (*Cache) Truncate

func (self *Cache) Truncate(ino uint64, size int64) (err error)

func (*Cache) WriteAt

func (self *Cache) WriteAt(ino uint64, buf []byte, off int64) (n int, err error)

type Config

type Config struct {
	// DirPathTimeout is the duration that Readdir will be satisfied from cache.
	// This value should be less than EvictDelay.
	DirPathTimeout time.Duration

	// DirPathMaxCount is the maximum count of directories cached.
	DirPathMaxCount int

	// NegPathTimeout is the duration that a negative lookup (ENOENT) is considered valid.
	NegPathTimeout time.Duration

	// NegPathMaxCount is the maximum count of negative lookups cached.
	NegPathMaxCount int

	// LoopPeriod is how often the background thread will run to upload and evict files.
	LoopPeriod time.Duration

	// UploadDelay is how long the background thread will wait before uploading a file.
	UploadDelay time.Duration

	// UploadDelay is how long the background thread will wait before evicting a file.
	EvictDelay time.Duration
}

Jump to

Keyboard shortcuts

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