disk_cache

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskCache

type DiskCache struct {
	// contains filtered or unexported fields
}

Blobstore is *almost* sufficient here, but blobstore doesn't handle record expirations in a way that make sense for a cache. So we keep a record (in memory) of file atime (Last Access Time) and size, and then when our cache reaches fullness we remove the most stale files. Rather than serialize this ledger, we regenerate it from scratch on startup by looking at the filesystem itself.

func NewDiskCache

func NewDiskCache(rootDir string, maxSizeBytes int64) (*DiskCache, error)

func (*DiskCache) Contains

func (c *DiskCache) Contains(ctx context.Context, d *repb.Digest) (bool, error)

func (*DiskCache) ContainsMulti

func (c *DiskCache) ContainsMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest]bool, error)

func (*DiskCache) Delete

func (c *DiskCache) Delete(ctx context.Context, d *repb.Digest) error

func (*DiskCache) Get

func (c *DiskCache) Get(ctx context.Context, d *repb.Digest) ([]byte, error)

func (*DiskCache) GetMulti

func (c *DiskCache) GetMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest][]byte, error)

func (*DiskCache) Reader

func (c *DiskCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.Reader, error)

func (*DiskCache) Set

func (c *DiskCache) Set(ctx context.Context, d *repb.Digest, data []byte) error

func (*DiskCache) SetMulti

func (c *DiskCache) SetMulti(ctx context.Context, kvs map[*repb.Digest][]byte) error

func (*DiskCache) Start

func (c *DiskCache) Start() error

func (*DiskCache) Stop

func (c *DiskCache) Stop() error

func (*DiskCache) WithPrefix

func (c *DiskCache) WithPrefix(prefix string) interfaces.Cache

func (*DiskCache) Writer

func (c *DiskCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL