structure

package
Version: v2.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 7 Imported by: 131

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashPair

type HashPair struct {
	Field []byte
	Value []byte
}

HashPair is the pair for (field, value) in a hash.

type TxStructure

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

TxStructure supports some simple data structures like string, hash, list, etc... and you can use these in a transaction.

func NewStructure

func NewStructure(reader kv.Retriever, readWriter kv.RetrieverMutator, prefix []byte) *TxStructure

NewStructure creates a TxStructure with Retriever, RetrieverMutator and key prefix.

func (*TxStructure) Clear

func (t *TxStructure) Clear(key []byte) error

Clear removes the string value of the key.

func (*TxStructure) EncodeHashAutoIDKeyValue

func (t *TxStructure) EncodeHashAutoIDKeyValue(key []byte, field []byte, val int64) (k, v []byte)

EncodeHashAutoIDKeyValue returns the hash key-value generated by the key and the field

func (*TxStructure) Get

func (t *TxStructure) Get(key []byte) ([]byte, error)

Get gets the string value of a key.

func (*TxStructure) GetInt64

func (t *TxStructure) GetInt64(key []byte) (int64, error)

GetInt64 gets the int64 value of a key.

func (*TxStructure) HClear

func (t *TxStructure) HClear(key []byte) error

HClear removes the hash value of the key.

func (*TxStructure) HDel

func (t *TxStructure) HDel(key []byte, fields ...[]byte) error

HDel deletes one or more hash fields.

func (*TxStructure) HGet

func (t *TxStructure) HGet(key []byte, field []byte) ([]byte, error)

HGet gets the value of a hash field.

func (*TxStructure) HGetAll

func (t *TxStructure) HGetAll(key []byte) ([]HashPair, error)

HGetAll gets all the fields and values in a hash.

func (*TxStructure) HGetInt64

func (t *TxStructure) HGetInt64(key []byte, field []byte) (int64, error)

HGetInt64 gets int64 value of a hash field.

func (*TxStructure) HInc

func (t *TxStructure) HInc(key []byte, field []byte, step int64) (int64, error)

HInc increments the integer value of a hash field, by step, returns the value after the increment.

func (*TxStructure) HKeys

func (t *TxStructure) HKeys(key []byte) ([][]byte, error)

HKeys gets all the fields in a hash.

func (*TxStructure) HLen

func (t *TxStructure) HLen(key []byte) (int64, error)

HLen gets the number of fields in a hash.

func (*TxStructure) HSet

func (t *TxStructure) HSet(key []byte, field []byte, value []byte) error

HSet sets the string value of a hash field.

func (*TxStructure) Inc

func (t *TxStructure) Inc(key []byte, step int64) (int64, error)

Inc increments the integer value of a key by step, returns the value after the increment.

func (*TxStructure) LClear

func (t *TxStructure) LClear(key []byte) error

LClear removes the list of the key.

func (*TxStructure) LGetAll

func (t *TxStructure) LGetAll(key []byte) ([][]byte, error)

LGetAll gets all elements of this list in order from right to left.

func (*TxStructure) LIndex

func (t *TxStructure) LIndex(key []byte, index int64) ([]byte, error)

LIndex gets an element from a list by its index.

func (*TxStructure) LLen

func (t *TxStructure) LLen(key []byte) (int64, error)

LLen gets the length of a list.

func (*TxStructure) LPop

func (t *TxStructure) LPop(key []byte) ([]byte, error)

LPop removes and gets the first element in a list.

func (*TxStructure) LPush

func (t *TxStructure) LPush(key []byte, values ...[]byte) error

LPush prepends one or multiple values to a list.

func (*TxStructure) LSet

func (t *TxStructure) LSet(key []byte, index int64, value []byte) error

LSet updates an element in the list by its index.

func (*TxStructure) RPop

func (t *TxStructure) RPop(key []byte) ([]byte, error)

RPop removes and gets the last element in a list.

func (*TxStructure) RPush

func (t *TxStructure) RPush(key []byte, values ...[]byte) error

RPush appends one or multiple values to a list.

func (*TxStructure) Set

func (t *TxStructure) Set(key []byte, value []byte) error

Set sets the string value of the key.

type TypeFlag

type TypeFlag byte

TypeFlag is for data structure meta/data flag.

const (
	// StringMeta is the flag for string meta.
	StringMeta TypeFlag = 'S'
	// StringData is the flag for string data.
	StringData TypeFlag = 's'
	// HashMeta is the flag for hash meta.
	HashMeta TypeFlag = 'H'
	// HashData is the flag for hash data.
	HashData TypeFlag = 'h'
	// ListMeta is the flag for list meta.
	ListMeta TypeFlag = 'L'
	// ListData is the flag for list data.
	ListData TypeFlag = 'l'
)

Jump to

Keyboard shortcuts

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