writecache

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package writecache implements write-cache for objects.

It contains in-memory cache of fixed size and underlying database (usually on SSD) for storing small objects. There are 3 places where object can be: 1. In-memory cache. 2. On-disk cache DB. 3. Main storage (blobstor).

There are 2 types of background jobs:

  1. Persisting objects from in-memory cache to database.
  2. Flushing objects from database to blobstor. On flushing object address is put in in-memory LRU cache. The actual deletion from the DB is done when object is evicted from this cache.

Putting objects to the main storage is done by multiple workers. Some of them prioritize flushing items, others prioritize putting new objects. The current ration is 50/50. This helps to make some progress even under load.

Index

Constants

This section is empty.

Variables

View Source
var ErrBigObject = errors.New("too big object")

ErrBigObject is returned when object is too big to be placed in cache.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(*objectSDK.Address) (*object.Object, error)
	Delete(*objectSDK.Address) error
	Put(*object.Object) error

	Init() error
	Open() error
	Close() error
}

Cache represents write-cache for objects.

func New

func New(opts ...Option) Cache

New creates new writecache instance.

type Option

type Option func(*options)

Option represents write-cache configuration option.

func WithBlobstor

func WithBlobstor(bs *blobstor.BlobStor) Option

WithBlobstor sets main object storage.

func WithFlushWorkersCount

func WithFlushWorkersCount(c int) Option

func WithLogger

func WithLogger(log *zap.Logger) Option

WithLogger sets logger.

func WithMaxDBSize

func WithMaxDBSize(sz uint64) Option

WithMaxDBSize sets maximum size for on-disk DB.

func WithMaxMemSize

func WithMaxMemSize(sz uint64) Option

WithMaxMemSize sets maximum size for in-memory DB.

func WithMaxObjectSize

func WithMaxObjectSize(sz uint64) Option

WithMaxObjectSize sets maximum object size to be stored in write-cache.

func WithMetabase

func WithMetabase(db *meta.DB) Option

WithMetabase sets metabase.

func WithPath

func WithPath(path string) Option

WithPath sets path to writecache db.

func WithSmallObjectSize

func WithSmallObjectSize(sz uint64) Option

WithSmallObjectSize sets maximum object size to be stored in write-cache.

Jump to

Keyboard shortcuts

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