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:
- Persisting objects from in-memory cache to database.
- 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 ¶
- Variables
- type Cache
- type ObjectCounters
- type Option
- func WithBlobstor(bs *blobstor.BlobStor) Option
- func WithFlushWorkersCount(c int) Option
- func WithLogger(log *zap.Logger) Option
- func WithMaxCacheSize(sz uint64) Option
- func WithMaxMemSize(sz uint64) Option
- func WithMaxObjectSize(sz uint64) Option
- func WithMetabase(db *meta.DB) Option
- func WithObjectCounters(v ObjectCounters) Option
- func WithPath(path string) Option
- func WithSmallObjectSize(sz uint64) Option
Constants ¶
This section is empty.
Variables ¶
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) Head(*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.
type ObjectCounters ¶ added in v0.25.0
type ObjectCounters interface { // Increments number of objects saved in DB. IncDB() // Decrements number of objects saved in DB. DecDB() // Returns number of objects saved in DB. DB() uint64 // Increments number of objects saved in FSTree. IncFS() // Decrements number of objects saved in FSTree. DecFS() // Returns number of objects saved in FSTree. FS() uint64 // Reads number of objects saved in write-cache. It is called on write-cache initialization step. Read() error // Flushes the values and closes the storage. It is called on write-cache shutdown. FlushAndClose() }
ObjectCounters is an interface of the storage of cached object amount.
type Option ¶
type Option func(*options)
Option represents write-cache configuration option.
func WithBlobstor ¶
WithBlobstor sets main object storage.
func WithFlushWorkersCount ¶
func WithMaxCacheSize ¶ added in v0.25.0
WithMaxCacheSize sets maximum write-cache size in bytes.
func WithMaxMemSize ¶
WithMaxMemSize sets maximum size for in-memory DB.
func WithMaxObjectSize ¶
WithMaxObjectSize sets maximum object size to be stored in write-cache.
func WithObjectCounters ¶ added in v0.25.0
func WithObjectCounters(v ObjectCounters) Option
WithObjectCounters sets ObjectCounters instance needed for cache write-cache size estimation.
func WithSmallObjectSize ¶
WithSmallObjectSize sets maximum object size to be stored in write-cache.