cache03

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TXT_SERVER_SIDE_UNIX_SOCKET = "Server Side UNIX Socket"

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) CreateCache

func (self *CacheDir) CreateCache() (*os.File, error)

func (*CacheDir) CreateSumForCache

func (self *CacheDir) CreateSumForCache(name string, signal bool) error

func (*CacheDir) Delete

func (self *CacheDir) Delete(name string)

func (*CacheDir) Disable

func (self *CacheDir) Disable(name string)

func (*CacheDir) Enable

func (self *CacheDir) Enable(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 may be suffixed with WorkExtension. it will be suffized automatically, if it isn't this function strips path from oname and uses only oname Base resulting values are joined with path, so they are full path names

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) GetServerNewItemSignalChan

func (self *CacheDir) GetServerNewItemSignalChan() <-chan EmptyStruct

func (*CacheDir) GetServerThreadWorker

func (self *CacheDir) GetServerThreadWorker() goworker.WorkerI

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) MakeSignalIfSocketEnabled

func (self *CacheDir) MakeSignalIfSocketEnabled() error

func (*CacheDir) NewNameForCache

func (self *CacheDir) NewNameForCache() string

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)

Put doesn't calls Close() on data

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

	// UnixSocketServerSide bool
	UnixSocketEnabled  bool
	UnixSocketFileName string
}

type EmptyStruct

type EmptyStruct struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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