store

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreventStoreMarshaling

type PreventStoreMarshaling struct {
	Store
}

PreventStoreMarshaling can wrap any Store implementation, embedding it to re-expose the full interface, overriding binary marshaling methods in order to produce (and expect) empty data.

In the context of spaGO models, this wrapper is a convenient way to prevent Store public fields from being marshaled when models are serialized (for example, using gob).

func (PreventStoreMarshaling) MarshalBinary

func (PreventStoreMarshaling) MarshalBinary() ([]byte, error)

MarshalBinary satisfies encoding.BinaryMarshaler interface. It always produces empty data (nil) and no error.

func (PreventStoreMarshaling) UnmarshalBinary

func (PreventStoreMarshaling) UnmarshalBinary(data []byte) error

UnmarshalBinary satisfies encoding.BinaryUnmarshaler interface. It only accepts empty data (nil or zero-length slice), producing no side effects at all. If data is not blank, it returns an error.

type Repository

type Repository interface {
	// Store returns a data store by name.
	Store(name string) (Store, error)
	// DropAll removes all data and drops all stores.
	DropAll() error
}

A Repository is a logical grouping of different stores.

type Store

type Store interface {
	// The Name of the store.
	Name() string
	// DropAll drops all data from the store.
	DropAll() error
	// Keys returns all the keys from the store.
	Keys() ([][]byte, error)
	// KeysCount reports how many key/value pairs are in the store.
	KeysCount() (int, error)
	// Contains reports whether the given key is found in the store.
	Contains(key []byte) (bool, error)
	// Put sets a key/value pair in the store.
	// If a value for the same key already exists in the store, it is
	// overwritten with the new value.
	Put(key []byte, value any) error
	// Get attempts to fetch the value associated with the key, assigning it
	// to the given parameter, and returns a flag which reports whether
	// the key has been found or not.
	Get(key []byte, value any) (bool, error)
}

Store is an interface to a single key-value store.

Directories

Path Synopsis
diskstore module

Jump to

Keyboard shortcuts

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