Documentation
¶
Index ¶
Constants ¶
Variables ¶
var ( ErrKeyExist = errors.New("key already exist") ErrFileDoesntExist = errors.New("file doesn't exist") ErrCacheSizeExceeded = errors.New("cache size exceeded") ErrMissingCacheDir = errors.New("missing cache directory") ErrPositiveMaxCacheSize = errors.New("cache size must be positive") ErrKeyDoesntExist = errors.New("key doesn't exist") ErrKeySetInProgress = errors.New("key set is in progress") ErrNegativeSize = errors.New("value size is negative") )
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer implements io.ReadWriteSeeker for testing purposes.
func NewBuffer ¶
NewBuffer returns buffer that implements io.ReadWriteSeeker
type FakeFileCache ¶
type FakeFileCache struct {
// contains filtered or unexported fields
}
func NewFakeFileCache ¶
func NewFakeFileCache() *FakeFileCache
func (*FakeFileCache) Get ¶
func (c *FakeFileCache) Get(key string) (io.ReadSeekCloser, error)
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache implements a file system backed cache, which makes it possible to store values as files on disk. Total cache size is specified by the total size of the data, rather than the amount of items. FileCache maintains index of all the items in a in-memory LRU cache, that allows to free up space by evicting oldest items.
func NewFileCache ¶
func NewFileCache(maxSize int64, dir string, options ...FileCacheOption) (*FileCache, error)
NewFileCache instantiates a new instance of FileCache. If the provided path does not exist, it will be created, otherwise existing files will be indexed and served from cache.
type FileCacheOption ¶
type FileCacheOption func(*FileCache)
FileCacheOption allows to set additional FileCache options
func WithIndexSize ¶
func WithIndexSize(i int) FileCacheOption
WithIndexSize allows to set maximum index size. Normally this is required only in tests.