Documentation ¶
Index ¶
- Variables
- type AccessorCache
- func (bc *AccessorCache) EnableMetrics() (unreg func() error, err error)
- func (bc *AccessorCache) Get(height uint64) (eds.AccessorStreamer, error)
- func (bc *AccessorCache) GetOrLoad(ctx context.Context, height uint64, loader OpenAccessorFn) (eds.AccessorStreamer, error)
- func (bc *AccessorCache) Has(height uint64) bool
- func (bc *AccessorCache) Remove(height uint64) error
- type Cache
- type DoubleCache
- func (mc *DoubleCache) EnableMetrics() (unreg func() error, err error)
- func (mc *DoubleCache) First() Cache
- func (mc *DoubleCache) Get(height uint64) (eds.AccessorStreamer, error)
- func (mc *DoubleCache) GetOrLoad(ctx context.Context, height uint64, loader OpenAccessorFn) (eds.AccessorStreamer, error)
- func (mc *DoubleCache) Has(height uint64) bool
- func (mc *DoubleCache) Remove(height uint64) error
- func (mc *DoubleCache) Second() Cache
- type NoopCache
- func (n NoopCache) EnableMetrics() (unreg func() error, err error)
- func (n NoopCache) Get(uint64) (eds.AccessorStreamer, error)
- func (n NoopCache) GetOrLoad(ctx context.Context, _ uint64, loader OpenAccessorFn) (eds.AccessorStreamer, error)
- func (n NoopCache) Has(uint64) bool
- func (n NoopCache) Remove(uint64) error
- type NoopFile
- func (n NoopFile) AxisHalf(context.Context, rsmt2d.Axis, int) (eds.AxisHalf, error)
- func (n NoopFile) AxisRoots(context.Context) (*share.AxisRoots, error)
- func (n NoopFile) Close() error
- func (n NoopFile) DataHash(context.Context) (share.DataHash, error)
- func (n NoopFile) Reader() (io.Reader, error)
- func (n NoopFile) RowNamespaceData(context.Context, share.Namespace, int) (shwap.RowNamespaceData, error)
- func (n NoopFile) Sample(context.Context, int, int) (shwap.Sample, error)
- func (n NoopFile) Shares(context.Context) ([]share.Share, error)
- func (n NoopFile) Size(context.Context) int
- type OpenAccessorFn
Constants ¶
This section is empty.
Variables ¶
var ErrCacheMiss = errors.New("accessor not found in cache")
Functions ¶
This section is empty.
Types ¶
type AccessorCache ¶
type AccessorCache struct {
// contains filtered or unexported fields
}
AccessorCache implements the Cache interface using an LRU cache backend.
func NewAccessorCache ¶
func NewAccessorCache(name string, cacheSize int) (*AccessorCache, error)
func (*AccessorCache) EnableMetrics ¶
func (bc *AccessorCache) EnableMetrics() (unreg func() error, err error)
EnableMetrics enables metrics for the cache.
func (*AccessorCache) Get ¶
func (bc *AccessorCache) Get(height uint64) (eds.AccessorStreamer, error)
Get retrieves the accessor for a given uint64 from the Cache. If the Accessor is not in the Cache, it returns an ErrCacheMiss.
func (*AccessorCache) GetOrLoad ¶
func (bc *AccessorCache) GetOrLoad( ctx context.Context, height uint64, loader OpenAccessorFn, ) (eds.AccessorStreamer, error)
GetOrLoad attempts to get an item from the cache, and if not found, invokes the provided loader function to load it.
func (*AccessorCache) Has ¶
func (bc *AccessorCache) Has(height uint64) bool
Has checks if accessor for the height is present on the AccessorCache.
func (*AccessorCache) Remove ¶
func (bc *AccessorCache) Remove(height uint64) error
Remove removes the Accessor for a given uint64 from the cache.
type Cache ¶
type Cache interface { // Has checks if the Cache contains the eds.AccessorStreamer for the given height. Has(height uint64) bool // Get returns the eds.AccessorStreamer for the given height. Get(height uint64) (eds.AccessorStreamer, 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(ctx context.Context, height uint64, open OpenAccessorFn) (eds.AccessorStreamer, error) // Remove removes an item from Cache. Remove(height uint64) error // EnableMetrics enables metrics in Cache EnableMetrics() (unreg func() error, err 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() (unreg func() error, err error)
func (*DoubleCache) First ¶
func (mc *DoubleCache) First() Cache
func (*DoubleCache) Get ¶
func (mc *DoubleCache) Get(height uint64) (eds.AccessorStreamer, error)
Get looks for an item in all the caches one by one and returns the Cache found item.
func (*DoubleCache) GetOrLoad ¶
func (mc *DoubleCache) GetOrLoad( ctx context.Context, height uint64, loader OpenAccessorFn, ) (eds.AccessorStreamer, error)
GetOrLoad attempts to get an item from the both caches and, if not found, invokes the provided loader function to load it into the first Cache.
func (*DoubleCache) Has ¶
func (mc *DoubleCache) Has(height uint64) bool
Has checks if accessor for the height is present on the AccessorCache.
func (*DoubleCache) Remove ¶
func (mc *DoubleCache) Remove(height uint64) error
Remove removes an item from all underlying caches
func (*DoubleCache) Second ¶
func (mc *DoubleCache) Second() Cache
type NoopCache ¶
type NoopCache struct{}
NoopCache implements noop version of Cache interface
func (NoopCache) EnableMetrics ¶
func (NoopCache) GetOrLoad ¶
func (n NoopCache) GetOrLoad(ctx context.Context, _ uint64, loader OpenAccessorFn) (eds.AccessorStreamer, error)
type NoopFile ¶
type NoopFile struct{}
NoopFile implements noop version of eds.AccessorStreamer interface
func (NoopFile) RowNamespaceData ¶
type OpenAccessorFn ¶
type OpenAccessorFn func(context.Context) (eds.AccessorStreamer, error)