cache

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCacheNoFound    = fmt.Errorf("cache no found")
	ErrFileNoNeedStore = fmt.Errorf("file no need store")
)

Functions

This section is empty.

Types

type Description

type Description struct {
	Name       string `json:"name"`
	Size       string `json:"size"`
	MD5        string `json:"md5"`
	ChangeTime int64  `json:"change_time"`
}

Description describe the file cache request it is as the file cache KEY

type File

type File interface {
	Name() string
	MD5() string
	AbsPath() string
	Dir() string
	SaveTo(string) error
	Equal(File) bool
	Size() int64
}

File describe the cache file instance

func NewFile

func NewFile(path string) (File, error)

NewFile get a new File instance

type Manager

type Manager interface {
	Search(Description) (File, error)
	Store(File) error
}

Manager describe the manager of file cache

func NewManager

func NewManager(c ManagerConfig) (Manager, error)

NewManager get a new file cache manager

type ManagerConfig

type ManagerConfig struct {
	CacheDir     string `json:"cache_dir"`
	PoolSize     int    `json:"pool_size"`
	CacheMinSize int64  `json:"cache_min_size"`
}

ManagerConfig describe the file cache manager config

Jump to

Keyboard shortcuts

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