Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeDataKey(dataFlag TypeFlag, prefix []byte, key []byte) kv.Key
- func EncodeHashMetaValue(expireAt int64, count int64) []byte
- func EncodeStringMetaValue(expire int64) []byte
- type HashPair
- type MetaValue
- type TxStructure
- func (t *TxStructure) CheckExpireAndDel(keys [][]byte) (bool, error)
- func (t *TxStructure) Clear(key []byte) error
- func (t *TxStructure) DEL(keys [][]byte) (int, error)
- func (t *TxStructure) EXPIRE(key []byte, ttl []byte) (int, error)
- func (t *TxStructure) EncodeMetaKey(key []byte) kv.Key
- func (t *TxStructure) ExpireAt(key []byte, ttl []byte) (int, error)
- 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) (int, error)
- func (t *TxStructure) HGet(key []byte, field []byte) ([]byte, error)
- func (t *TxStructure) HGetAll(key []byte) ([][]byte, error)
- func (t *TxStructure) HGetInt64(key []byte, field []byte) (int64, error)
- func (t *TxStructure) HInc(key []byte, field []byte, step int64) (int64, error)
- func (t *TxStructure) HKeys(key []byte) ([][]byte, error)
- func (t *TxStructure) HLen(key []byte) (int, error)
- func (t *TxStructure) HMSet(key []byte, elements []*HashPair) ([]byte, error)
- func (t *TxStructure) HSet(key []byte, field []byte, value []byte) (int, error)
- func (t *TxStructure) IncInt64(key []byte, step int64) (int64, error)
- func (t *TxStructure) LClear(key []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) MergedHClear(key []byte) error
- func (t *TxStructure) MergedHDel(key []byte, fields [][]byte) (int, error)
- func (t *TxStructure) MergedHGet(key []byte, field []byte) ([]byte, error)
- func (t *TxStructure) MergedHGetAll(key []byte) ([][]byte, error)
- func (t *TxStructure) MergedHGetInt64(key []byte, field []byte) (int64, error)
- func (t *TxStructure) MergedHIncInt64(key []byte, field []byte, step int64) (int64, error)
- func (t *TxStructure) MergedHKeys(key []byte) ([][]byte, error)
- func (t *TxStructure) MergedHMGet(key []byte, fields [][]byte) ([][]byte, error)
- func (t *TxStructure) MergedHMSet(key []byte, elements []*HashPair) ([]byte, error)
- func (t *TxStructure) MergedHSet(key []byte, field []byte, value []byte) (int, 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) ([]byte, error)
- func (t *TxStructure) SetWithTTL(key []byte, value []byte, ttl int64) ([]byte, error)
- func (t *TxStructure) TTL(key []byte) (int, error)
- type TypeFlag
Constants ¶
const (
SeekThreshold int = 10
)
Variables ¶
var ( ErrSetType = errors.New("invalid set type") ErrInvalidTTL = errors.New("invalid ttl value") ErrIncrValue = errors.New("ERR value is not an integer or out of range") )
var (
InvalidFlag = errors.New("invalid flag")
)
Functions ¶
func EncodeHashMetaValue ¶
func EncodeStringMetaValue ¶
Types ¶
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, ignorettl bool) *TxStructure
NewStructure creates a TxStructure with Retriever, RetrieverMutator and key prefix.
func (*TxStructure) CheckExpireAndDel ¶
func (t *TxStructure) CheckExpireAndDel(keys [][]byte) (bool, error)
func (*TxStructure) Clear ¶
func (t *TxStructure) Clear(key []byte) error
Clear removes the string value of the key.
func (*TxStructure) EncodeMetaKey ¶
func (t *TxStructure) EncodeMetaKey(key []byte) kv.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) (int, 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) ([][]byte, 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 ¶
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) (int, error)
HLen gets the number of fields in a hash.
func (*TxStructure) HMSet ¶
func (t *TxStructure) HMSet(key []byte, elements []*HashPair) ([]byte, error)
func (*TxStructure) IncInt64 ¶
func (t *TxStructure) IncInt64(key []byte, step int64) (int64, error)
func (*TxStructure) LClear ¶
func (t *TxStructure) LClear(key []byte) error
LClear removes the list of the key.
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) MergedHClear ¶
func (t *TxStructure) MergedHClear(key []byte) error
func (*TxStructure) MergedHDel ¶
func (t *TxStructure) MergedHDel(key []byte, fields [][]byte) (int, error)
HDel deletes one or more hash fields.
func (*TxStructure) MergedHGet ¶
func (t *TxStructure) MergedHGet(key []byte, field []byte) ([]byte, error)
func (*TxStructure) MergedHGetAll ¶
func (t *TxStructure) MergedHGetAll(key []byte) ([][]byte, error)
func (*TxStructure) MergedHGetInt64 ¶
func (t *TxStructure) MergedHGetInt64(key []byte, field []byte) (int64, error)
func (*TxStructure) MergedHIncInt64 ¶
func (*TxStructure) MergedHKeys ¶
func (t *TxStructure) MergedHKeys(key []byte) ([][]byte, error)
func (*TxStructure) MergedHMGet ¶
func (t *TxStructure) MergedHMGet(key []byte, fields [][]byte) ([][]byte, error)
func (*TxStructure) MergedHMSet ¶
func (t *TxStructure) MergedHMSet(key []byte, elements []*HashPair) ([]byte, error)
func (*TxStructure) MergedHSet ¶
HSet sets the string value of a hash field.
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) ([]byte, error)
Set sets the string value of the key.
func (*TxStructure) SetWithTTL ¶
type TypeFlag ¶
type TypeFlag byte
TypeFlag is for data structure meta/data flag.
const ( MetaCode TypeFlag = '#' DataCode TypeFlag = '&' // 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' ERRCode TypeFlag = 'E' )