cache

package
v0.14.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCacheMiss = errors.New("accessor not found in blockstore cache")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns the EDS file for the given key.
	Get(key) (file.EdsFile, error)

	// GetOrLoad attempts to get an item from the Cache and, if not found, invokes
	// the provided loader function to load it into the Cache.
	GetOrLoad(context.Context, key, OpenFileFn) (file.EdsFile, error)

	// Remove removes an item from Cache.
	Remove(key) error

	// EnableMetrics enables metrics in Cache
	EnableMetrics() error
}

Cache is an interface that defines the basic Cache operations.

type DoubleCache

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

DoubleCache represents a Cache that looks into multiple caches one by one.

func NewDoubleCache

func NewDoubleCache(first, second Cache) *DoubleCache

NewDoubleCache creates a new DoubleCache with the provided caches.

func (*DoubleCache) EnableMetrics

func (mc *DoubleCache) EnableMetrics() error

func (*DoubleCache) First

func (mc *DoubleCache) First() Cache

func (*DoubleCache) Get

func (mc *DoubleCache) Get(key key) (file.EdsFile, error)

Get looks for an item in all the caches one by one and returns the Cache found item.

func (*DoubleCache) Remove

func (mc *DoubleCache) Remove(key key) error

Remove removes an item from all underlying caches

func (*DoubleCache) Second

func (mc *DoubleCache) Second() Cache

type FileCache

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

FileCache implements the Cache interface using an LRU cache backend.

func NewFileCache

func NewFileCache(name string, cacheSize int) (*FileCache, error)

func (*FileCache) EnableMetrics

func (bc *FileCache) EnableMetrics() error

EnableMetrics enables metrics for the cache.

func (*FileCache) Get

func (bc *FileCache) Get(key key) (file.EdsFile, error)

Get retrieves the accessor for a given key from the Cache. If the Accessor is not in the Cache, it returns an ErrCacheMiss.

func (*FileCache) GetOrLoad

func (bc *FileCache) GetOrLoad(ctx context.Context, key key, loader OpenFileFn) (file.EdsFile, error)

GetOrLoad attempts to get an item from the cache, and if not found, invokes the provided loader function to load it.

func (*FileCache) Remove

func (bc *FileCache) Remove(key key) error

Remove removes the Accessor for a given key from the cache.

type NoopCache

type NoopCache struct{}

NoopCache implements noop version of Cache interface

func (NoopCache) EnableMetrics

func (n NoopCache) EnableMetrics() error

func (NoopCache) Get

func (n NoopCache) Get(key) (file.EdsFile, error)

func (NoopCache) GetOrLoad

func (n NoopCache) GetOrLoad(ctx context.Context, _ key, loader OpenFileFn) (file.EdsFile, error)

func (NoopCache) Remove

func (n NoopCache) Remove(key) error

type NoopFile

type NoopFile struct{}

NoopFile implements noop version of file.EdsFile interface

func (NoopFile) AxisHalf

func (n NoopFile) AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) ([]share.Share, error)

func (NoopFile) Close

func (n NoopFile) Close() error

func (NoopFile) Data

func (n NoopFile) Data(ctx context.Context, namespace share.Namespace, rowIdx int) (share.NamespacedRow, error)

func (NoopFile) DataHash

func (n NoopFile) DataHash() share.DataHash

func (NoopFile) EDS

func (NoopFile) Height

func (n NoopFile) Height() uint64

func (NoopFile) Reader

func (n NoopFile) Reader() (io.Reader, error)

func (NoopFile) Share

func (n NoopFile) Share(ctx context.Context, x, y int) (*share.ShareWithProof, error)

func (NoopFile) Size

func (n NoopFile) Size() int

type OpenFileFn

type OpenFileFn func(context.Context) (file.EdsFile, error)

Jump to

Keyboard shortcuts

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