store

package
v0.0.0-...-7899014 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound   = errors.New("key not found")
	ErrKeyNotMatch   = errors.New("key not match")
	ErrRead          = errors.New("read error")
	ErrIgnore        = errors.New("ignore")
	ErrReadDisabled  = errors.New("read disabled")
	ErrWriteDisabled = errors.New("write disabled")
	ErrClosed        = context.Canceled
)
View Source
var Break = errors.New("break")

Functions

This section is empty.

Types

type Cache

type Cache interface {
	CacheGet(Key, func(sb.Stream) error) error

	// CachePut must save tokens as encoded form
	CachePut(Key, sb.Tokens, ...CachePutOption) error
}

type CachePutOption

type CachePutOption interface {
	IsCachePutOption()
}

type Def

type Def struct{}

func (Def) NewMemCache

func (Def) NewMemCache(
	newHashState key.NewHashState,
) NewMemCache

func (Def) Scrub

func (Def) Scrub(
	newHashState key.NewHashState,
	parallel sys.Parallel,
) Scrub

func (Def) StoreID

func (Def) StoreID(
	store Store,
) ID

func (Def) TestStore

func (Def) TestStore(
	scrub Scrub,
) TestStore

type EncodedLen

type EncodedLen int

func (EncodedLen) IsCachePutOption

func (EncodedLen) IsCachePutOption()

type Hash

type Hash = key.Hash

type ID

type ID string

type Key

type Key = key.Key

type MemCache

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

func (*MemCache) CacheGet

func (m *MemCache) CacheGet(key Key, fn func(sb.Stream) error) (err error)

func (*MemCache) CachePut

func (m *MemCache) CachePut(
	key Key,
	tokens sb.Tokens,
	options ...CachePutOption,
) error

type NewMemCache

type NewMemCache func(
	maxKeys int,
	maxSize int,
) (*MemCache, error)

type Scrub

type Scrub func(
	ctx context.Context,
	store Store,
	options ...ScrubOption,
) error

type ScrubOption

type ScrubOption interface {
	IsScrubOption()
}

type Store

type Store interface {
	ID() (ID, error)
	Name() string

	Write(
		key.Namespace,
		sb.Stream,
		...WriteOption,
	) (
		WriteResult,
		error,
	)

	Read(
		Key,
		func(sb.Stream) error,
	) error

	Exists(
		Key,
	) (bool, error)

	IterKeys(
		key.Namespace,
		func(Key) error,
	) error

	IterAllKeys(
		fn func(Key) error,
	) error

	Delete(
		[]Key,
	) error
}

type TapWriteResult

type TapWriteResult func(WriteResult)

func (TapWriteResult) IsSaveOption

func (TapWriteResult) IsSaveOption()

func (TapWriteResult) IsWriteOption

func (TapWriteResult) IsWriteOption()

type TestStore

type TestStore func(
	ctx context.Context,
	withStore func(
		fn func(Store),
		provides ...any,
	),
	t *testing.T,
)

test Store implementation

type WriteOption

type WriteOption interface {
	IsWriteOption()
}

type WriteResult

type WriteResult struct {
	Key          Key
	Written      bool
	BytesWritten int64
}

Jump to

Keyboard shortcuts

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