writecache

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package writecache implements write-cache for objects.

Write-cache uses file system tree for storing objects.

Flushing from the writecache to the main storage is done in the background.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOutOfSpace is returned when there is no space left to put a new object.
	ErrOutOfSpace = errors.New("no space left in the write cache")
)
View Source
var ErrReadOnly = logicerr.New("write-cache is in read-only mode")

ErrReadOnly is returned when Put/Write is performed in a read-only mode.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(address oid.Address) (*object.Object, error)
	// GetBytes reads object from the Cache by address into memory buffer in a
	// canonical NeoFS binary format. Returns [apistatus.ObjectNotFound] if object
	// is missing.
	GetBytes(oid.Address) ([]byte, error)
	Head(oid.Address) (*object.Object, error)
	// Delete removes object referenced by the given oid.Address from the
	// Cache. Returns any error encountered that prevented the object to be
	// removed.
	//
	// Returns apistatus.ObjectNotFound if object is missing in the Cache.
	// Returns ErrReadOnly if the Cache is currently in the read-only mode.
	Delete(oid.Address) error
	Iterate(func(oid.Address, []byte) error, bool) error
	Put(oid.Address, *object.Object, []byte) error
	SetMode(mode.Mode) error
	SetLogger(*zap.Logger)
	SetShardIDMetrics(string)
	DumpInfo() Info
	Flush(bool) error

	Init() error
	Open(readOnly bool) error
	Close() error
	ObjectStatus(address oid.Address) (ObjectStatus, error)
}

Cache represents write-cache for objects.

func New

func New(opts ...Option) Cache

New creates new writecache instance.

type Info added in v0.27.2

type Info struct {
	// Full path to the write-cache.
	Path string
}

Info groups the information about write-cache.

type ObjectStatus added in v0.39.0

type ObjectStatus struct {
	PathFSTree string
}

ObjectStatus represents the status of the object in the Writecache.

type Option

type Option func(*options)

Option represents write-cache configuration option.

func WithFlushWorkersCount

func WithFlushWorkersCount(c int) Option

WithFlushWorkersCount sets number of workers to flushing objects in parallel.

func WithLogger

func WithLogger(log *zap.Logger) Option

WithLogger sets logger.

func WithMaxCacheSize added in v0.25.0

func WithMaxCacheSize(sz uint64) Option

WithMaxCacheSize sets maximum write-cache size in bytes.

func WithMaxFlushBatchCount added in v0.46.0

func WithMaxFlushBatchCount(c int) Option

WithMaxFlushBatchCount sets maximum batch delay to flush small objects.

func WithMaxFlushBatchSize added in v0.46.0

func WithMaxFlushBatchSize(sz uint64) Option

WithMaxFlushBatchSize sets maximum batch size to flush.

func WithMaxFlushBatchThreshold added in v0.46.0

func WithMaxFlushBatchThreshold(sz uint64) Option

WithMaxFlushBatchThreshold sets maximum size of small object to put in batch.

func WithMetrics added in v0.46.0

func WithMetrics(m metricRegister) Option

WithMetrics sets a metrics register instance for write-cache.

func WithNoSync added in v0.36.0

func WithNoSync(noSync bool) Option

WithNoSync sets an option to allow returning to caller on PUT before write is persisted.

func WithPath

func WithPath(path string) Option

WithPath sets path to writecache db.

func WithReportErrorFunc added in v0.36.0

func WithReportErrorFunc(f func(string, error)) Option

WithReportErrorFunc sets error reporting function.

func WithStorage added in v0.47.0

func WithStorage(s common.Storage) Option

WithStorage sets main object storage.

Jump to

Keyboard shortcuts

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