Documentation ¶
Index ¶
- Variables
- type HashPair
- type ReverseHashIterator
- type TxStructure
- func (t *TxStructure) Clear(key []byte) error
- func (t *TxStructure) EncodeHashAutoIDKeyValue(key []byte, field []byte, val int64) (k, v []byte)
- func (t *TxStructure) EncodeHashDataKey(key []byte, field []byte) kv.Key
- func (t *TxStructure) EncodeStringDataKey(key []byte) kv.Key
- func (t *TxStructure) Get(key []byte) ([]byte, error)
- func (t *TxStructure) GetInt64(key []byte) (int64, error)
- func (t *TxStructure) HClear(key []byte) error
- func (t *TxStructure) HDel(key []byte, fields ...[]byte) error
- func (t *TxStructure) HGet(key []byte, field []byte) ([]byte, error)
- func (t *TxStructure) HGetAll(key []byte) ([]HashPair, error)
- func (t *TxStructure) HGetInt64(key []byte, field []byte) (int64, error)
- func (t *TxStructure) HGetIter(key []byte, fn func(pair HashPair) error) error
- func (t *TxStructure) HGetLastN(key []byte, num int) ([]HashPair, error)
- func (t *TxStructure) HGetLen(key []byte) (uint64, error)
- func (t *TxStructure) HInc(key []byte, field []byte, step int64) (int64, error)
- func (t *TxStructure) HKeys(key []byte) ([][]byte, error)
- func (t *TxStructure) HSet(key []byte, field []byte, value []byte) error
- func (t *TxStructure) Inc(key []byte, step int64) (int64, error)
- func (t *TxStructure) LClear(key []byte) error
- func (t *TxStructure) LGetAll(key []byte) ([][]byte, error)
- func (t *TxStructure) LIndex(key []byte, index int64) ([]byte, error)
- func (t *TxStructure) LLen(key []byte) (int64, error)
- func (t *TxStructure) LPop(key []byte) ([]byte, error)
- func (t *TxStructure) LPush(key []byte, values ...[]byte) error
- func (t *TxStructure) LSet(key []byte, index int64, value []byte) error
- func (t *TxStructure) RPop(key []byte) ([]byte, error)
- func (t *TxStructure) RPush(key []byte, values ...[]byte) error
- func (t *TxStructure) Set(key []byte, value []byte) error
- type TypeFlag
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidHashKeyFlag used by structure ErrInvalidHashKeyFlag = dbterror.ClassStructure.NewStd(mysql.ErrInvalidHashKeyFlag) // ErrInvalidListIndex used by structure ErrInvalidListIndex = dbterror.ClassStructure.NewStd(mysql.ErrInvalidListIndex) // ErrInvalidListMetaData used by structure ErrInvalidListMetaData = dbterror.ClassStructure.NewStd(mysql.ErrInvalidListMetaData) // ErrWriteOnSnapshot used by structure ErrWriteOnSnapshot = dbterror.ClassStructure.NewStd(mysql.ErrWriteOnSnapshot) )
Functions ¶
This section is empty.
Types ¶
type ReverseHashIterator ¶
type ReverseHashIterator struct {
// contains filtered or unexported fields
}
ReverseHashIterator is the reverse hash iterator.
func NewHashReverseIter ¶
func NewHashReverseIter(t *TxStructure, key []byte) (*ReverseHashIterator, error)
NewHashReverseIter creates a reverse hash iterator.
func NewHashReverseIterBeginWithField ¶
func NewHashReverseIterBeginWithField(t *TxStructure, key []byte, field []byte) (*ReverseHashIterator, error)
NewHashReverseIterBeginWithField creates a reverse hash iterator, begin with field.
func (*ReverseHashIterator) Close ¶
func (*ReverseHashIterator) Close()
Close Implements the Iterator Close.
func (*ReverseHashIterator) Key ¶
func (i *ReverseHashIterator) Key() []byte
Key implements the Iterator Key.
func (*ReverseHashIterator) Next ¶
func (i *ReverseHashIterator) Next() error
Next implements the Iterator Next.
func (*ReverseHashIterator) Valid ¶
func (i *ReverseHashIterator) Valid() bool
Valid implements the Iterator Valid.
func (*ReverseHashIterator) Value ¶
func (i *ReverseHashIterator) Value() []byte
Value implements the Iterator Value.
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) EncodeHashDataKey ¶
func (t *TxStructure) EncodeHashDataKey(key []byte, field []byte) kv.Key
EncodeHashDataKey exports for tests.
func (*TxStructure) EncodeStringDataKey ¶
func (t *TxStructure) EncodeStringDataKey(key []byte) kv.Key
EncodeStringDataKey will encode string key.
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) HGetIter ¶
func (t *TxStructure) HGetIter(key []byte, fn func(pair HashPair) error) error
HGetIter iterates all the fields and values in hash.
func (*TxStructure) HGetLastN ¶
func (t *TxStructure) HGetLastN(key []byte, num int) ([]HashPair, error)
HGetLastN gets latest N fields and values in hash.
func (*TxStructure) HGetLen ¶
func (t *TxStructure) HGetLen(key []byte) (uint64, error)
HGetLen gets the length of hash.
func (*TxStructure) HInc ¶
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) 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.
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' )