slicecache

package
v0.0.0-...-30c4c12 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacheable

type Cacheable interface {
	Cache() ShardCache
}

Cacheable indicates a slice's data should be cached.

type FileShardCache

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

FileShardCache is a ShardCache backed by files. A nil *FileShardCache has no cached data.

func NewFileShardCache

func NewFileShardCache(ctx context.Context, prefix string, numShards int) *FileShardCache

NewShardCache constructs a ShardCache. It does O(numShards) parallelized file operations to look up what's present in the cache.

func (*FileShardCache) CacheReader

func (c *FileShardCache) CacheReader(shard int) sliceio.Reader

CacheReader returns a reader that reads from the cache. If the shard is not cached, returns a reader that will always return an error.

func (*FileShardCache) IsCached

func (c *FileShardCache) IsCached(shard int) bool

func (*FileShardCache) RequireAllCached

func (c *FileShardCache) RequireAllCached()

func (*FileShardCache) WritethroughReader

func (c *FileShardCache) WritethroughReader(shard int, reader sliceio.Reader) sliceio.Reader

WritethroughReader returns a reader that populates the cache. reader should read computed data.

type ShardCache

type ShardCache interface {
	IsCached(shard int) bool
	WritethroughReader(shard int, reader sliceio.Reader) sliceio.Reader
	CacheReader(shard int) sliceio.Reader
}

ShardCache accesses cached data for a slice's shards.

var Empty ShardCache = empty{}

Empty is an empty cache.

Jump to

Keyboard shortcuts

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