Documentation ¶
Index ¶
- Variables
- type Cache
- func (c *Cache) Clear() error
- func (c *Cache) Delete(key string) error
- func (c *Cache) DeleteIf(key string, removeTest func(tag []byte) bool) (bool, error)
- func (c *Cache) Dump()
- func (c *Cache) Empty() bool
- func (c *Cache) Get(key string) (ReadSeekCloser, int64, error)
- func (c *Cache) GetStats() Stats
- func (c *Cache) GetTag(key string) ([]byte, error)
- func (c *Cache) GetWithTag(key string) (ReadSeekCloser, []byte, int64, error)
- func (c *Cache) Keys() []string
- func (c *Cache) NumEntries() int64
- func (c *Cache) Put(key string, val []byte) error
- func (c *Cache) PutReader(key string, r LazyReader) (io.ReadCloser, error)
- func (c *Cache) PutReaderWithTag(key string, tag []byte, lr LazyReader) (io.ReadCloser, error)
- func (c *Cache) PutWithTag(key string, tag, val []byte) error
- func (c *Cache) ResetStats()
- func (c *Cache) SetTag(key string, tag []byte) error
- func (c *Cache) Size() int64
- type ChunkCache
- func (c *ChunkCache) Clear() error
- func (c *ChunkCache) Delete(key string) error
- func (c *ChunkCache) DeleteChunk(key string, offset int64) error
- func (c *ChunkCache) Empty() bool
- func (c *ChunkCache) Get(key string, offset int64) (ReadSeekCloser, int64, error)
- func (c *ChunkCache) GetCommonTag(key string) ([]byte, error)
- func (c *ChunkCache) GetStats() Stats
- func (c *ChunkCache) GetTag(key string, offset int64) ([]byte, error)
- func (c *ChunkCache) GetWithTag(key string, offset int64) (ReadSeekCloser, []byte, int64, error)
- func (c *ChunkCache) Keys() []string
- func (c *ChunkCache) NumChunksOf(key string) (int64, error)
- func (c *ChunkCache) NumEntries() int64
- func (c *ChunkCache) NumTotalChunks() int64
- func (c *ChunkCache) Put(key string, offset int64, val []byte) error
- func (c *ChunkCache) PutReader(key string, offset int64, r LazyReader) (io.ReadCloser, error)
- func (c *ChunkCache) PutReaderWithTag(key string, offset int64, tag []byte, lz LazyReader) (io.ReadCloser, error)
- func (c *ChunkCache) PutWithTag(key string, offset int64, tag []byte, val []byte) error
- func (c *ChunkCache) ResetStats()
- func (c *ChunkCache) SetTag(key string, offset int64, tag []byte) error
- func (c *ChunkCache) SetUntaggedChunks(key string, tag []byte) (int, error)
- func (c *ChunkCache) Shrink()
- func (c *ChunkCache) Size() int64
- func (c *ChunkCache) WaitPut(key string)
- type EntryStatus
- type FileEntry
- type FileError
- type LazyReader
- type Meta
- type ReadSeekCloser
- type Stats
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrBadDir = errors.New("invalid directory") ErrBadSize = errors.New("storage size must be greater then zero") ErrBadCap = errors.New("file number must be greater then zero") ErrTooLarge = errors.New("file size must be less or equal storage size") ErrUntagged = errors.New("file is not tagged") ErrAlreadyTagged = errors.New("file is already tagged") ErrChunkNotFound = errors.New("chunk not found") ErrIncoherentTag = errors.New("incoherent tag") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
New creates a Cache backed by dir on disk. The cache allows at most c files of total size sz.
func (*Cache) Clear ¶ added in v1.3.0
Clear resets the cache and erases the files from the cache directory.
func (*Cache) DeleteIf ¶ added in v1.5.0
Delete a key from the cache if the given lambda returns true, do nothing otherwise.
func (*Cache) Dump ¶ added in v1.6.5
func (c *Cache) Dump()
Dump the content on the cache for debugging.
func (*Cache) Get ¶
func (c *Cache) Get(key string) (ReadSeekCloser, int64, error)
Get returns a reader for a blob in the cache, or ErrNotFound otherwise.
func (*Cache) GetWithTag ¶ added in v1.4.0
GetWithTag returns a reader for a blob in the cache along with the associated tag, or ErrNotFound otherwise.
func (*Cache) NumEntries ¶ added in v1.5.0
numEntries returns the number of entries in the cache.
func (*Cache) PutReader ¶
func (c *Cache) PutReader(key string, r LazyReader) (io.ReadCloser, error)
PutReader adds the contents of a lazy reader as a blob to the cache against the given key.
func (*Cache) PutReaderWithTag ¶ added in v1.4.0
func (c *Cache) PutReaderWithTag(key string, tag []byte, lr LazyReader) (io.ReadCloser, error)
PutReaderWithTag like PutReader, adds the contents of a reader as blog along with a tag annotation against the given key.
func (*Cache) PutWithTag ¶ added in v1.4.0
Put like Put, adds a byte slice as a blob along with a tag annotation.
func (*Cache) ResetStats ¶ added in v1.3.0
func (c *Cache) ResetStats()
ResetStats resets the statistics of the cache.
type ChunkCache ¶
func NewChunkCache ¶
func NewChunkCache(dir string, sz, c int64) (*ChunkCache, error)
func (*ChunkCache) Clear ¶
func (c *ChunkCache) Clear() error
func (*ChunkCache) Delete ¶
func (c *ChunkCache) Delete(key string) error
func (*ChunkCache) DeleteChunk ¶
func (c *ChunkCache) DeleteChunk(key string, offset int64) error
func (*ChunkCache) Empty ¶
func (c *ChunkCache) Empty() bool
func (*ChunkCache) Get ¶
func (c *ChunkCache) Get(key string, offset int64) (ReadSeekCloser, int64, error)
func (*ChunkCache) GetCommonTag ¶
func (c *ChunkCache) GetCommonTag(key string) ([]byte, error)
func (*ChunkCache) GetStats ¶
func (c *ChunkCache) GetStats() Stats
func (*ChunkCache) GetWithTag ¶
func (c *ChunkCache) GetWithTag(key string, offset int64) (ReadSeekCloser, []byte, int64, error)
func (*ChunkCache) Keys ¶
func (c *ChunkCache) Keys() []string
func (*ChunkCache) NumChunksOf ¶
func (c *ChunkCache) NumChunksOf(key string) (int64, error)
func (*ChunkCache) NumEntries ¶
func (c *ChunkCache) NumEntries() int64
func (*ChunkCache) NumTotalChunks ¶
func (c *ChunkCache) NumTotalChunks() int64
func (*ChunkCache) PutReader ¶
func (c *ChunkCache) PutReader(key string, offset int64, r LazyReader) (io.ReadCloser, error)
func (*ChunkCache) PutReaderWithTag ¶
func (c *ChunkCache) PutReaderWithTag(key string, offset int64, tag []byte, lz LazyReader) (io.ReadCloser, error)
func (*ChunkCache) PutWithTag ¶
func (*ChunkCache) ResetStats ¶
func (c *ChunkCache) ResetStats()
func (*ChunkCache) SetUntaggedChunks ¶
func (c *ChunkCache) SetUntaggedChunks(key string, tag []byte) (int, error)
func (*ChunkCache) Shrink ¶
func (c *ChunkCache) Shrink()
func (*ChunkCache) Size ¶
func (c *ChunkCache) Size() int64
func (*ChunkCache) WaitPut ¶
func (c *ChunkCache) WaitPut(key string)
type EntryStatus ¶
type EntryStatus int64
const ( EntryBusy EntryStatus = iota EntryReady EntryDeleted )
type LazyReader ¶
type LazyReader func() (io.ReadCloser, error)
func NewLazyReader ¶
func NewLazyReader(r io.ReadCloser) LazyReader
func NewLazyReaderFromBuffer ¶
func NewLazyReaderFromBuffer(buf []byte) LazyReader
type Meta ¶
type Meta struct { Key string Size int64 Path string Tag []byte // user annotation Status EntryStatus }
Meta is the information about the cache entry.