kv

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderNone = Order(0)
	OrderAsc  = Order(1)
	OrderDesc = Order(2)
)

Order options.

Variables

View Source
var CollectionKeyHeader = kv.CollectionKeyHeader
View Source
var DatabaseKeyHeader = kv.DatabaseKeyHeader
View Source
var DocumentKeyHeader = kv.DocumentKeyHeader
View Source
var ErrNotExist = document.ErrNotExist
View Source
var NoLimit = int(0)

NoLimit represents a no limit option.

View Source
var NoOffset = uint(0)

NoOffset represents a no offset option.

View Source
var PrimaryIndexHeader = kv.PrimaryIndexHeader
View Source
var SecondaryIndexHeader = kv.SecondaryIndexHeader

Functions

func NewErrObjectNotExist added in v1.3.0

func NewErrObjectNotExist(key kv.Key) error

Types

type HeaderType

type HeaderType = kv.HeaderType

KeyHeader represents a key header in the key-value store.

type Key

type Key = kv.Key

Key represents a key in the key-value store.

func NewKeyWith

func NewKeyWith(header KeyHeader, key Key) Key

NewKeyWith returns a new key from the specified header and key elements.

type KeyHeader

type KeyHeader = kv.KeyHeader

KeyHeader represents a header for all keys.

type LimitOption added in v1.0.0

type LimitOption struct {
	Limit int
}

LimitOption represents a limit option.

func NewLimitOption added in v1.0.0

func NewLimitOption(limit int) *LimitOption

NewLimitOption returns a new limit option.

type Object

type Object struct {
	Key   Key
	Value []byte
}

Object represents a key-value object.

func NewObject added in v1.0.0

func NewObject(key Key, value []byte) *Object

NewObject returns a new object.

type OffsetOption added in v1.0.0

type OffsetOption struct {
	Offset uint
}

OffsetOption represents an offset option.

func NewOffsetOption added in v1.0.0

func NewOffsetOption(offset uint) *OffsetOption

NewLimitOption returns a new offset option.

type Option added in v1.0.0

type Option = any

Option represents a option.

type Order added in v1.0.0

type Order = int

Order represents a order.

type OrderOption added in v1.0.0

type OrderOption struct {
	Order Order
}

OrderOption represents a order option.

func NewOrderOptionWith added in v1.0.0

func NewOrderOptionWith(order Order) *OrderOption

NewOrderOptionWith returns a new order option.

type ResultSet

type ResultSet interface {
	// Next moves the cursor forward next object from its current position.
	Next() bool
	// Object returns an object in the current position.
	Object() *Object
}

ResultSet represents a result set which includes query execution results.

type Store

type Store interface {
	document.KeyCoder
	// SetKeyCoder sets the key coder.
	SetKeyCoder(coder document.KeyCoder)
	// Transact begin a new transaction.
	Transact(write bool) (Transaction, error)
}

Store represents a store interface.

type Transaction

type Transaction interface {
	// Set stores a key-value object. If the key already holds some value, it is overwritten.
	Set(obj *Object) error
	// Get returns a key-value object of the specified key.
	Get(key Key) (*Object, error)
	// GetRange returns a result set of the specified key.
	GetRange(key Key, opts ...Option) (ResultSet, error)
	// Remove removes the specified key-value object.
	Remove(key Key) error
	// RemoveRange removes the specified key-value objects.
	RemoveRange(key Key) error
	// Commit commits this transaction.
	Commit() error
	// Cancel cancels this transaction.
	Cancel() error
	// SetTimeout sets the timeout of this transaction.
	SetTimeout(t time.Duration) error
}

Transaction represents a transaction interface.

Jump to

Keyboard shortcuts

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