Documentation
¶
Index ¶
- Variables
- func Get(db *bbolt.DB, key []byte) ([]byte, error)
- func IterateDB(db *bbolt.DB, f func(oid.Address) error) error
- func New(opts ...Option) writecache.Cache
- func OpenDB(p string, ro bool, openFile func(string, int, fs.FileMode) (*os.File, error)) (*bbolt.DB, error)
- type Option
- func WithBlobstor(bs writecache.MainStorage) Option
- func WithFlushWorkersCount(c int) Option
- func WithLogger(log *logger.Logger) Option
- func WithMaxBatchDelay(d time.Duration) Option
- func WithMaxBatchSize(sz int) Option
- func WithMaxCacheSize(sz uint64) Option
- func WithMaxObjectSize(sz uint64) Option
- func WithMetabase(db writecache.Metabase) Option
- func WithMetrics(metrics writecache.Metrics) Option
- func WithNoSync(noSync bool) Option
- func WithOpenFile(f func(string, int, fs.FileMode) (*os.File, error)) Option
- func WithPath(path string) Option
- func WithReportErrorFunc(f func(string, error)) Option
- func WithSmallObjectSize(sz uint64) Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBigObject is returned when object is too big to be placed in cache. ErrBigObject = errors.New("too big object") // ErrOutOfSpace is returned when there is no space left to put a new object. ErrOutOfSpace = errors.New("no space left in the write cache") )
var ErrNoDefaultBucket = errors.New("no default bucket")
ErrNoDefaultBucket is returned by IterateDB when default bucket for objects is missing.
Functions ¶
func Get ¶
Get fetches object from the underlying database. Key should be a stringified address.
Returns an error of type apistatus.ObjectNotFound if the requested object is missing in db.
func IterateDB ¶
IterateDB iterates over all objects stored in bbolt.DB instance and passes them to f until error return. It is assumed that db is an underlying database of some WriteCache instance.
Returns ErrNoDefaultBucket if there is no default bucket in db.
DB must not be nil and should be opened.
Types ¶
type Option ¶
type Option func(*options)
Option represents write-cache configuration option.
func WithBlobstor ¶
func WithBlobstor(bs writecache.MainStorage) Option
WithBlobstor sets main object storage.
func WithFlushWorkersCount ¶
func WithMaxBatchDelay ¶
WithMaxBatchDelay sets max batch delay for the small object database.
func WithMaxBatchSize ¶
WithMaxBatchSize sets max batch size for the small object database.
func WithMaxCacheSize ¶
WithMaxCacheSize sets maximum write-cache size in bytes.
func WithMaxObjectSize ¶
WithMaxObjectSize sets maximum object size to be stored in write-cache.
func WithMetrics ¶
func WithMetrics(metrics writecache.Metrics) Option
WithMetrics sets metrics implementation.
func WithNoSync ¶
WithNoSync sets an option to allow returning to caller on PUT before write is persisted. Note, that we use this flag for FSTree only and DO NOT use it for a bolt DB because we cannot yet properly handle the corrupted database during the startup. This SHOULD NOT be relied upon and may be changed in future.
func WithOpenFile ¶
WithOpenFile sets the OpenFile function to use internally by bolt. Useful for hermetic testing.
func WithReportErrorFunc ¶
WithReportErrorFunc sets error reporting function.
func WithSmallObjectSize ¶
WithSmallObjectSize sets maximum object size to be stored in write-cache.