cache02

package
v0.0.0-...-9799ab4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheDir

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

func NewCacheDir

func NewCacheDir(options *CacheDirOptions) *CacheDir

func (*CacheDir) CheckFileIntegrity

func (self *CacheDir) CheckFileIntegrity(name string) (ok bool, fullpath string, err error)

func (*CacheDir) ComparisonFunction

func (self *CacheDir) ComparisonFunction(f1, f2 os.FileInfo) (int, error)

func (*CacheDir) Delete

func (self *CacheDir) Delete(name string)

func (*CacheDir) Disable

func (self *CacheDir) Disable(name string)

func (*CacheDir) EnsureDirectory

func (self *CacheDir) EnsureDirectory(
	try_create_dir bool,
	try_write_file bool,
) error

Ensure directory acceptable to be used for file storage

func (*CacheDir) GenNames

func (self *CacheDir) GenNames(oname string) (name, name_disabled, name_sum, name_sum_disabled string)

TODO: probaby, this function requires optimization oname must be suffixed with WorkExtension. it will be suffized automatically, if it's not

func (*CacheDir) Get

func (self *CacheDir) Get() (name string, data io.ReadCloser, err error)

Get() locks file with returned name, so Get() can be called asyncronously and Get() will not return locked files. files can be unlocked with Unlock(), Disable() or Delete() functions

func (*CacheDir) HaveCache

func (self *CacheDir) HaveCache() (bool, error)

func (*CacheDir) JoinFileName

func (self *CacheDir) JoinFileName(filename string) string

preforms filepath joining of directory path and provided filename

func (*CacheDir) NextFile

func (self *CacheDir) NextFile() (name string, err error)

err = os.ErrNotExist if no any file found. acceptable filenames should be already checked by self.WorkingFiles() so NextFile() only find's the oldest one and treats any errors as not acceptable

func (*CacheDir) ParseWorkFileName

func (self *CacheDir) ParseWorkFileName(n string) (t time.Time, err error)

func (*CacheDir) ParseWorkFileNameByFileInfo

func (self *CacheDir) ParseWorkFileNameByFileInfo(fi os.FileInfo) (t time.Time, err error)

func (*CacheDir) Put

func (self *CacheDir) Put(data io.Reader) (err error)

func (*CacheDir) UnlockFile

func (self *CacheDir) UnlockFile(name string)

func (*CacheDir) WorkingFiles

func (self *CacheDir) WorkingFiles() (ret []os.FileInfo, err error)

type CacheDirOptions

type CacheDirOptions struct {
	DirPath       string
	WorkExtension string

	HashMaker     func() hash.Hash
	HashExtension string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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