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 }
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
Click to show internal directories.
Click to hide internal directories.