Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobCache ¶
type BlobCache interface {
// Add returns a writer to add contents to cache
Add(key string, opts ...Option) (Writer, error)
// Get returns a reader to read the specified contents
// from cache
Get(key string, opts ...Option) (Reader, error)
// Close closes the cache
Close() error
}
BlobCache represents a cache for bytes data
func NewDirectoryCache ¶
func NewDirectoryCache(directory string, config DirectoryCacheConfig) (BlobCache, error)
func NewMemoryCache ¶
func NewMemoryCache() BlobCache
type DirectoryCacheConfig ¶
type DirectoryCacheConfig struct {
// Number of entries of LRU cache (default: 10).
// This won't be used when DataCache is specified.
MaxLRUCacheEntry int
// Number of file descriptors to cache (default: 10).
// This won't be used when FdCache is specified.
MaxCacheFds int
// On Add, wait until the data is fully written to the cache directory.
SyncAdd bool
// DataCache is an on-memory cache of the data.
// OnEvicted will be overridden and replaced for internal use.
DataCache *cacheutil.LRUCache
// FdCache is a cache for opened file descriptors.
// OnEvicted will be overridden and replaced for internal use.
FdCache *cacheutil.LRUCache
// BufPool will be used for pooling bytes.Buffer.
BufPool *sync.Pool
// Direct forcefully enables direct mode for all operation in cache.
// Thus operation won't use on-memory caches.
Direct bool
// FadvDontNeed forcefully clean fscache pagecache for saving memory.
FadvDontNeed bool
}
type MemoryCache ¶ added in v0.6.0
type MemoryCache struct {
Membuf map[string]*bytes.Buffer
// contains filtered or unexported fields
}
MemoryCache is a cache implementation which backend is a memory.
func (*MemoryCache) Add ¶ added in v0.6.0
func (mc *MemoryCache) Add(key string, opts ...Option) (Writer, error)
func (*MemoryCache) Close ¶ added in v0.6.0
func (mc *MemoryCache) Close() error
type Option ¶
type Option func(o *cacheOpt) *cacheOpt
func Direct ¶
func Direct() Option
Direct option lets FetchAt and Add methods not to use on-memory caches. When you know that the targeting value won't be used immediately, you can prevent the limited space of on-memory caches from being polluted by these unimportant values.
func PassThrough ¶ added in v0.17.0
func PassThrough() Option
PassThrough option indicates whether to enable FUSE passthrough mode to improve local file read performance.
Click to show internal directories.
Click to hide internal directories.