Documentation ¶
Overview ¶
Package pagecache provides the implementation of a caching layer for files implementing the io.ReaderAt interface.
Index ¶
Constants ¶
const ( // DefaultPageSize is the default page size used when creating a Cache // instance. DefaultPageSize = 4096 // DefaultPageCount is the default page count used when creating a Cache // instance. DefaultPageCount = 16384 )
Variables ¶
var ( // ErrNoPages is returned when memory pressure is too high and it is not // possible to read files through the page cache. ErrNoPages = errors.New("there are no free pages left in the cache") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache instances implement the page caching layer of files.
func New ¶
New constructs a new Cache instance, using the list of options passed as arguments to configure the cache.
func NewWithConfig ¶
NewWithConfig is like New but uses a Config instance to pass the cache configuration instead of a list of options.
func (*Cache) NewFile ¶
NewFile constructs a wrapper around the file of the given size. id is a unique identifier intended to uniquely represent the file within the cache. If multiple io.ReaderAt interfaces point at the same underlying file, they could share the same id to reference the same pages in the cache.
type Config ¶
Config carries the configuration for the page cache.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig constructs a new Config instance initialized with the default configuration.
type Option ¶
type Option interface {
Configure(*Config)
}
Option is an interface implemented by options allowing configuration of new Cache instances.
type Stats ¶
type Stats struct { Lookups int64 // reads from the cache Hits int64 // page reads that were found in the cache Inserts int64 // pages inserted in the cache Evictions int64 // pages evicted from the cache Allocs int64 // number of free pages allocated by the cache Frees int64 // number of allocated pages returned to the free pool }
Stats is a structure carrying statistics collected on cache access.
All counters are absolute values accumulated since a cache instance was created.