wbstore

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package wbstore implements a wrapper for a blob.Store that caches non-replacement writes of in a buffer and pushes them to the base store concurrently in the background.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements the blob.Store interface by delegating to a base store. Non-replacement writes to blob.KV instances derived from the base store are buffered and written back to the underlying store by a background worker that runs concurrently with the store.

func New

func New(ctx context.Context, base blob.Store, buf blob.KV) Store

New constructs a blob.Store wrapper that delegates to base and uses buf as a local buffer store. New will panic if base == nil or buf == nil. The ctx value governs the operation of the background writer, which will run until the store is closed or ctx terminates.

If the buffer store is not empty, existing blobs there will be discarded.

func (Store) Buffer

func (s Store) Buffer() blob.KV

Buffer returns the buffer store used by s.

func (Store) CAS added in v0.9.0

func (s Store) CAS(ctx context.Context, name string) (blob.CAS, error)

CAS implements part of the blob.Store interface.

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close implements part of the blob.StoreCloser interface.

func (Store) KV added in v0.9.0

func (s Store) KV(ctx context.Context, name string) (blob.KV, error)

KV implements part of blob.Store. It wraps the blob.KV produced by the base store to direct writes through the buffer.

If the blob.KV returned by the base store implements blob.CAS, then the returned wrapper does also. Otherwise it does not.

func (Store) Sub added in v0.8.0

func (s Store) Sub(ctx context.Context, name string) (blob.Store, error)

Sub implements part of blob.Store. It wraps the substore produced by the base store to direct writes through the buffer.

func (Store) Sync

func (s Store) Sync(ctx context.Context) error

Sync blocks until the buffer is empty or ctx ends.

Jump to

Keyboard shortcuts

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