Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.Define("filecache: file not found") ErrAlreadyExists = errors.Define("filecache: file at path already exists") ErrFailedRefresh = errors.Define("filecache: failed refreshing cache entry") ErrFileTooLarge = errors.Define("filecache: file too large") ErrClosed = errors.Define("filecache: closed") )
View Source
var DefaultConfig = Config{ RefreshFreq: time.Minute, Size: 100, MaxSize: int64(1024 * 1000 * 5), MaxAge: time.Minute * 30, EvictionCallback: func(path string, file File) { log.Printf("FileCache evicted '%s'", path) }, ErrorEvictionCallback: func(path string, file File, err error) { log.Printf("FileCache evicted '%s' due to error: %v", path, err) }, }
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
type CacheEntry struct {
// contains filtered or unexported fields
}
func (*CacheEntry) Bytes ¶
func (e *CacheEntry) Bytes() []byte
func (*CacheEntry) Reader ¶
func (e *CacheEntry) Reader() io.Reader
func (*CacheEntry) Release ¶
func (e *CacheEntry) Release()
type Config ¶
type Config struct { // RefreshFreq is the frequency at which the refresh routines operates RefreshFreq time.Duration // Size is the fixed size of the FileCache Size int // MaxSize is the maximum size of files permitted in the cache MaxSize int64 // MaxAge is the maximum time entries can go unused in // the cache before being marked for eviction. The minimum age // (and granularity) is 1 second MaxAge time.Duration // AllowOverwrites signifies whether to overwrite existing // files of the same path when passed to .Put() AllowOverwrites bool // EvictionCallback is called when a file is evicted from the FileCache EvictionCallback func(path string, file File) // ErrorEvictionCallback is called when a file is evicted from the FileCache // due to an error, e.g. cannot stat, file too large, etc ErrorEvictionCallback func(path string, file File, err error) }
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache is an LRU cache with filesystem monitoring. UpgradeableMutex is built-in to the FileCache and CachedFile objects it manages for multi-threading
Click to show internal directories.
Click to hide internal directories.