package cache
import "github.com/containerd/stargz-snapshotter/cache"
Index ¶
- type BlobCache
- func NewDirectoryCache(directory string, config DirectoryCacheConfig) (BlobCache, error)
- func NewMemoryCache() BlobCache
- type DirectoryCacheConfig
- type MemoryCache
- func (mc *MemoryCache) Add(key string, opts ...Option) (Writer, error)
- func (mc *MemoryCache) Close() error
- func (mc *MemoryCache) Get(key string, opts ...Option) (Reader, error)
- type Option
- type Reader
- type Writer
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 ¶
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 ¶
func (mc *MemoryCache) Add(key string, opts ...Option) (Writer, error)
func (*MemoryCache) Close ¶
func (mc *MemoryCache) Close() error
func (*MemoryCache) Get ¶
func (mc *MemoryCache) Get(key string, opts ...Option) (Reader, 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.
type Reader ¶
Reader provides the data cached.
type Writer ¶
type Writer interface { io.WriteCloser Commit() error Abort() error }
Writer enables the client to cache byte data. Commit() must be called after data is fully written to Write(). To abort the written data, Abort() must be called.
Source Files ¶
- Version
- v0.16.3 (latest)
- Published
- Dec 12, 2024
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 2 weeks ago –
Tools for package owners.