Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvictStats ¶
type EvictStats struct { // CacheSize is the size of the cache before evicting. CacheSize int64 // Evicted is the number of items evicted. Evicted int }
EvictStats is information gathered during Evict.
type Fetcher ¶
type Fetcher func(context.Context) (io.ReadCloser, error)
Fetcher returns a ReadCloser. It is used by Open if the key is not in the cache.
type Store ¶
type Store struct { // Dir is the directory to cache items. Dir string // Component when set is reported to OpenTracing as the component. Component string // BackgroundTimeout when non-zero will do fetches in the background with // a timeout. This means the context passed to fetch will be // context.WithTimeout(context.Background(), BackgroundTimeout). When not // set fetches are done with the passed in context. BackgroundTimeout time.Duration // BeforeEvict, when non-nil, is a function to call before evicting a file. // It is passed the path to the file to be evicted. BeforeEvict func(string) // MaxCacheSizeBytes is the maximum size of the cache directory after evicting // entries. MaxCacheSizeBytes int64 }
Store is an on disk cache, with items cached via calls to Open.
func (*Store) Evict ¶
func (s *Store) Evict()
Evict will remove files from Store.Dir until it is smaller than Store.MaxCacheSizeBytes. It evicts files with the oldest modification time first.
func (*Store) EvictMaxSize ¶
func (s *Store) EvictMaxSize(maxCacheSizeBytes int64) (stats EvictStats, err error)
Evict will remove files from Store.Dir until it is smaller than maxCacheSizeBytes. It evicts files with the oldest modification time first.
Click to show internal directories.
Click to hide internal directories.