disk_cache

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 14 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, key string) (bool, error)

func (*DiskCache) Delete

func (c *DiskCache) Delete(ctx context.Context, key string) error

func (*DiskCache) Get

func (c *DiskCache) Get(ctx context.Context, key string) ([]byte, error)

func (*DiskCache) PrefixKey added in v1.0.4

func (c *DiskCache) PrefixKey(ctx context.Context, blobName string) (string, error)

func (*DiskCache) Reader

func (c *DiskCache) Reader(ctx context.Context, key string, offset, length int64) (io.Reader, error)

func (*DiskCache) Set

func (c *DiskCache) Set(ctx context.Context, key string, data []byte) error

func (*DiskCache) Start

func (c *DiskCache) Start() error

func (*DiskCache) Stop

func (c *DiskCache) Stop() error

func (*DiskCache) Writer

func (c *DiskCache) Writer(ctx context.Context, key string) (io.WriteCloser, error)

Jump to

Keyboard shortcuts

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