cache

package
v2.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is the part of the localstore which keeps track of the chunks that are not part of the reserve but are potentially useful to store for obtaining bandwidth incentives.

func New

func New(ctx context.Context, store storage.Reader, capacity uint64) (*Cache, error)

New creates a new Cache component with the specified capacity. The store is used here only to read the initial state of the cache before shutdown if there was any.

func (*Cache) Capacity

func (c *Cache) Capacity() uint64

Capacity returns the capacity of the cache.

func (*Cache) Getter

func (c *Cache) Getter(store transaction.Storage) storage.Getter

Getter returns a Storage.Getter instance which checks if the chunks accessed are part of cache it will update the cache indexes. If the operation to update the cache indexes fail, we need to fail the operation as this should signal the user of this getter to rollback the operation.

func (*Cache) Putter

func (c *Cache) Putter(store transaction.Storage) storage.Putter

Putter returns a Storage.Putter instance which adds the chunk to the underlying chunkstore and also adds a Cache entry for the chunk.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest(ctx context.Context, st transaction.Storage, count uint64) error

RemoveOldest removes the oldest cache entries from the store. The count specifies the number of entries to remove.

func (*Cache) ShallowCopy

func (c *Cache) ShallowCopy(
	ctx context.Context,
	store transaction.Storage,
	addrs ...swarm.Address,
) (err error)

ShallowCopy creates cache entries with the expectation that the chunk already exists in the chunkstore.

func (*Cache) Size

func (c *Cache) Size() uint64

Size returns the current size of the cache.

type CacheEntryItem

type CacheEntryItem = cacheEntry

exported for migration

Jump to

Keyboard shortcuts

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