tidis

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// tenant length should be less than 250, 251-255 can be used by system
	LeaderKey  = 251
	GCPointKey = 252
)
View Source
const (
	LHeadDirection uint8 = 0
	LTailDirection uint8 = 1

	LItemMinIndex uint64 = 1024
	LItemMaxIndex uint64 = 1<<64 - 1024

	LItemInitIndex uint64 = 1<<32 - 512
)
View Source
const (
	TSTRING byte = iota
	TLISTMETA
	TLISTDATA
	THASHMETA
	THASHDATA
	TSETMETA
	TSETDATA
	TZSETMETA
	TZSETSCORE
	TZSETDATA
	TTTLMETA
	TTTLDATA
)
View Source
const (
	FNORMAL byte = iota
	FDELETED
)
View Source
const (
	ObjectData byte = iota
	ObjectTTL
)
View Source
const (
	MetaTypeKey byte = iota
	DataTypeKey
	ScoreTypeKey
)

Variables

View Source
var (
	ScoreMin int64 = math.MinInt64 + 2
	ScoreMax int64 = math.MaxInt64 - 1
)
View Source
var (
	EmptyListOrSet []interface{} = make([]interface{}, 0)
)

Functions

func MarshalHashObj added in v1.0.0

func MarshalHashObj(obj *HashObj) []byte

func MarshalListObj added in v1.0.0

func MarshalListObj(obj *ListObj) []byte

func MarshalObj added in v1.0.0

func MarshalObj(obj IObject) []byte

func MarshalSetObj added in v1.0.0

func MarshalSetObj(obj *SetObj) []byte

func MarshalStringObj added in v1.0.0

func MarshalStringObj(obj *StringObj) []byte

func MarshalZSetObj added in v1.0.0

func MarshalZSetObj(obj *ZSetObj) []byte

func NewGCChecker added in v1.1.0

func NewGCChecker(interval, timeout, concurrency int, tdb *Tidis) *gcChecker

func NewLeaderChecker added in v1.1.0

func NewLeaderChecker(interval, duration int, tdb *Tidis) *leaderChecker

func NewTTLChecker

func NewTTLChecker(datatype byte, max, interval int, tdb *Tidis) *ttlChecker

func RawDBPrefix added in v1.0.0

func RawDBPrefix(tenantId string, dbId uint8) []byte

func RawKeyPrefix added in v1.0.0

func RawKeyPrefix(tenantid string, dbid uint8, key []byte) []byte

tenantlen(2)|tenant|dbid(1)|typedata(1)|userkeylen(4)|userkey

func RawSysGCPointKey added in v1.1.0

func RawSysGCPointKey() []byte

func RawSysLeaderKey added in v1.1.0

func RawSysLeaderKey() []byte

func RawTenantPrefix added in v1.0.0

func RawTenantPrefix(tenantId string) []byte

func ZScoreDecoder

func ZScoreDecoder(rawkeyPrefixLen int, rawkey []byte) (int64, []byte, error)

func ZScoreOffset

func ZScoreOffset(score int64) uint64

func ZScoreRestore

func ZScoreRestore(rscore uint64) int64

Types

type AsyncDelItem

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

type HashObj added in v1.0.0

type HashObj struct {
	Object
	Size uint64
}

func UnmarshalHashObj added in v1.0.0

func UnmarshalHashObj(raw []byte) (*HashObj, error)

type IObject added in v1.0.0

type IObject interface {
	ObjectExpired(now uint64) bool
	SetExpireAt(ts uint64)
	TTL(now uint64) uint64
	IsExpireSet() bool
}

type ListObj added in v1.0.0

type ListObj struct {
	Object
	Head uint64
	Tail uint64
	Size uint64
}

func UnmarshalListObj added in v1.0.0

func UnmarshalListObj(raw []byte) (*ListObj, error)

type MemberPair

type MemberPair struct {
	Score  int64
	Member []byte
}

type Object added in v1.0.0

type Object struct {
	Type     byte
	Tomb     byte
	ExpireAt uint64
}

func (*Object) IsExpireSet added in v1.0.0

func (obj *Object) IsExpireSet() bool

func (*Object) ObjectExpired added in v1.0.0

func (obj *Object) ObjectExpired(now uint64) bool

func (*Object) SetExpireAt added in v1.0.0

func (obj *Object) SetExpireAt(ts uint64)

func (*Object) TTL added in v1.0.0

func (obj *Object) TTL(now uint64) uint64

type SetObj added in v1.0.0

type SetObj struct {
	Object
	Size uint64
}

func UnmarshalSetObj added in v1.0.0

func UnmarshalSetObj(raw []byte) (*SetObj, error)

type StringObj added in v1.0.0

type StringObj struct {
	Object
	Value []byte
}

func UnmarshalStringObj added in v1.0.0

func UnmarshalStringObj(raw []byte) (*StringObj, error)

type Tidis

type Tidis struct {
	Lock sync.Mutex
	// contains filtered or unexported fields
}

func NewTidis

func NewTidis(conf *config.Config) (*Tidis, error)

func (*Tidis) AsyncDelAdd

func (tidis *Tidis) AsyncDelAdd(keyType byte, ukey []byte) error

func (*Tidis) AsyncDelDone

func (tidis *Tidis) AsyncDelDone(keyType byte, ukey []byte) error

func (*Tidis) CheckLeader added in v1.1.0

func (tidis *Tidis) CheckLeader(leaderLeaseDuration int)

func (*Tidis) Close

func (tidis *Tidis) Close() error

func (*Tidis) Decr

func (tidis *Tidis) Decr(dbId uint8, key []byte, step int64) (int64, error)

func (*Tidis) DecrWithTxn

func (tidis *Tidis) DecrWithTxn(dbId uint8, txn interface{}, key []byte, step int64) (int64, error)

func (*Tidis) Delete

func (tidis *Tidis) Delete(dbId uint8, txn interface{}, keys [][]byte) (int, error)

Delete is a generic api for all type keys

func (*Tidis) Expire

func (tidis *Tidis) Expire(dbId uint8, key []byte, s int64) (int, error)

func (*Tidis) ExpireAt

func (tidis *Tidis) ExpireAt(dbId uint8, key []byte, ts int64) (int, error)

func (*Tidis) ExpireAtWithTxn

func (tidis *Tidis) ExpireAtWithTxn(dbId uint8, txn interface{}, key []byte, ts int64) (int, error)

func (*Tidis) ExpireWithTxn

func (tidis *Tidis) ExpireWithTxn(dbId uint8, txn interface{}, key []byte, s int64) (int, error)

func (*Tidis) FlushAll added in v1.0.0

func (tidis *Tidis) FlushAll() error

func (*Tidis) FlushDB added in v1.0.0

func (tidis *Tidis) FlushDB(dbId uint8) error

func (*Tidis) Get

func (tidis *Tidis) Get(dbId uint8, txn interface{}, key []byte) ([]byte, error)

func (*Tidis) GetCurrentVersion added in v1.1.0

func (tidis *Tidis) GetCurrentVersion() (uint64, error)

func (*Tidis) GetObject added in v1.0.0

func (tidis *Tidis) GetObject(dbId uint8, txn interface{}, key []byte) (byte, IObject, error)

func (*Tidis) HashMetaObj added in v1.0.0

func (tidis *Tidis) HashMetaObj(dbId uint8, txn interface{}, key []byte) (*HashObj, error)

func (*Tidis) HashMetaObjWithExpire added in v1.0.0

func (tidis *Tidis) HashMetaObjWithExpire(dbId uint8, txn interface{}, key []byte, checkExpire bool) (*HashObj, error)

func (*Tidis) Hclear

func (tidis *Tidis) Hclear(dbId uint8, key []byte) (uint8, error)

func (*Tidis) HclearWithTxn

func (tidis *Tidis) HclearWithTxn(dbId uint8, txn1 interface{}, key []byte) (uint8, error)

func (*Tidis) Hdel

func (tidis *Tidis) Hdel(dbId uint8, key []byte, fields ...[]byte) (uint64, error)

func (*Tidis) HdelWithTxn

func (tidis *Tidis) HdelWithTxn(dbId uint8, txn interface{}, key []byte, fields ...[]byte) (uint64, error)

func (*Tidis) Hexists

func (tidis *Tidis) Hexists(dbId uint8, txn interface{}, key, field []byte) (bool, error)

func (*Tidis) Hget

func (tidis *Tidis) Hget(dbId uint8, txn interface{}, key, field []byte) ([]byte, error)

func (*Tidis) Hgetall

func (tidis *Tidis) Hgetall(dbId uint8, txn interface{}, key []byte) ([]interface{}, error)

func (*Tidis) Hkeys

func (tidis *Tidis) Hkeys(dbId uint8, txn interface{}, key []byte) ([]interface{}, error)

func (*Tidis) Hlen

func (tidis *Tidis) Hlen(dbId uint8, txn interface{}, key []byte) (uint64, error)

func (*Tidis) Hmget

func (tidis *Tidis) Hmget(dbId uint8, txn interface{}, key []byte, fields ...[]byte) ([]interface{}, error)

func (*Tidis) Hmset

func (tidis *Tidis) Hmset(dbId uint8, key []byte, fieldsvalues ...[]byte) error

Deprecated

func (*Tidis) HmsetWithTxn

func (tidis *Tidis) HmsetWithTxn(dbId uint8, txn interface{}, key []byte, fieldsvalues ...[]byte) error

Deprecated

func (*Tidis) Hset

func (tidis *Tidis) Hset(dbId uint8, key, field, value []byte) (uint8, error)

func (*Tidis) HsetWithTxn

func (tidis *Tidis) HsetWithTxn(dbId uint8, txn interface{}, key, field, value []byte) (uint8, error)

func (*Tidis) Hsetnx

func (tidis *Tidis) Hsetnx(dbId uint8, key, field, value []byte) (uint8, error)

func (*Tidis) HsetnxWithTxn

func (tidis *Tidis) HsetnxWithTxn(dbId uint8, txn interface{}, key, field, value []byte) (uint8, error)

func (*Tidis) Hstrlen

func (tidis *Tidis) Hstrlen(dbId uint8, txn interface{}, key, field []byte) (int, error)

func (*Tidis) Hvals

func (tidis *Tidis) Hvals(dbId uint8, txn interface{}, key []byte) ([]interface{}, error)

func (*Tidis) Incr

func (tidis *Tidis) Incr(dbId uint8, key []byte, step int64) (int64, error)

func (*Tidis) IncrWithTxn

func (tidis *Tidis) IncrWithTxn(dbId uint8, txn interface{}, key []byte, step int64) (int64, error)

func (*Tidis) IsLeader added in v1.1.0

func (tidis *Tidis) IsLeader() bool

func (*Tidis) LdelWithTxn

func (tidis *Tidis) LdelWithTxn(dbId uint8, txn1 interface{}, key []byte) (int, error)

func (*Tidis) Ldelete

func (tidis *Tidis) Ldelete(dbId uint8, key []byte) (int, error)

func (*Tidis) Lindex

func (tidis *Tidis) Lindex(dbId uint8, txn interface{}, key []byte, index int64) ([]byte, error)

func (*Tidis) ListMetaObj added in v1.0.0

func (tidis *Tidis) ListMetaObj(dbId uint8, txn, ss interface{}, key []byte) (*ListObj, bool, error)

func (*Tidis) ListMetaObjWithExpire added in v1.0.0

func (tidis *Tidis) ListMetaObjWithExpire(dbId uint8, txn, ss interface{}, key []byte, checkExpire bool) (*ListObj, bool, error)

func (*Tidis) Llen

func (tidis *Tidis) Llen(dbId uint8, txn interface{}, key []byte) (uint64, error)

func (*Tidis) Lpop

func (tidis *Tidis) Lpop(dbId uint8, txn interface{}, key []byte) ([]byte, error)

func (*Tidis) Lpush

func (tidis *Tidis) Lpush(dbId uint8, txn interface{}, key []byte, items ...[]byte) (uint64, error)

func (*Tidis) Lrange

func (tidis *Tidis) Lrange(dbId uint8, txn interface{}, key []byte, start, stop int64) ([]interface{}, error)

return map[string][]byte key is encoded key, not user key

func (*Tidis) Lset

func (tidis *Tidis) Lset(dbId uint8, key []byte, index int64, value []byte) error

func (*Tidis) LsetWithTxn

func (tidis *Tidis) LsetWithTxn(dbId uint8, txn interface{}, key []byte, index int64, value []byte) error

func (*Tidis) Ltrim

func (tidis *Tidis) Ltrim(dbId uint8, key []byte, start, stop int64) error

func (*Tidis) LtrimWithTxn

func (tidis *Tidis) LtrimWithTxn(dbId uint8, txn interface{}, key []byte, start, stop int64) error

func (*Tidis) MGet

func (tidis *Tidis) MGet(dbId uint8, txn interface{}, keys [][]byte) ([]interface{}, error)

func (*Tidis) MSet

func (tidis *Tidis) MSet(dbId uint8, txn interface{}, keyvals [][]byte) (int, error)

func (*Tidis) NewTxn

func (tidis *Tidis) NewTxn() (interface{}, error)

func (*Tidis) PExpire

func (tidis *Tidis) PExpire(dbId uint8, key []byte, ms int64) (int, error)

func (*Tidis) PExpireAt

func (tidis *Tidis) PExpireAt(dbId uint8, key []byte, ts int64) (int, error)

expire is also a series generic commands for all kind type keys

func (*Tidis) PExpireAtWithTxn

func (tidis *Tidis) PExpireAtWithTxn(dbId uint8, txn interface{}, key []byte, ts int64) (int, error)

func (*Tidis) PExpireWithTxn

func (tidis *Tidis) PExpireWithTxn(dbId uint8, txn interface{}, key []byte, ms int64) (int, error)

func (*Tidis) PTtl

func (tidis *Tidis) PTtl(dbId uint8, txn interface{}, key []byte) (int64, error)

generic command

func (*Tidis) RawHashDataKey added in v1.0.0

func (tidis *Tidis) RawHashDataKey(dbId uint8, key, field []byte) []byte

func (*Tidis) RawKeyPrefix added in v1.0.0

func (tidis *Tidis) RawKeyPrefix(dbid uint8, key []byte) []byte

func (*Tidis) RawListKey added in v1.0.0

func (tidis *Tidis) RawListKey(dbId uint8, key []byte, idx uint64) []byte

func (*Tidis) RawSetDataKey added in v1.0.0

func (tidis *Tidis) RawSetDataKey(dbId uint8, key, member []byte) []byte

func (*Tidis) RawZSetDataKey added in v1.0.0

func (tidis *Tidis) RawZSetDataKey(dbId uint8, key, member []byte) []byte

func (*Tidis) RawZSetScoreKey added in v1.0.0

func (tidis *Tidis) RawZSetScoreKey(dbId uint8, key, member []byte, score int64) []byte

func (*Tidis) Rpop

func (tidis *Tidis) Rpop(dbId uint8, txn interface{}, key []byte) ([]byte, error)

func (*Tidis) Rpush

func (tidis *Tidis) Rpush(dbId uint8, txn interface{}, key []byte, items ...[]byte) (uint64, error)

func (*Tidis) RunAsync

func (tidis *Tidis) RunAsync(ctx context.Context)

func (*Tidis) RunGC added in v1.1.0

func (tidis *Tidis) RunGC(safePoint uint64, concurrency int) error

func (*Tidis) Sadd

func (tidis *Tidis) Sadd(dbId uint8, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) SaddWithTxn

func (tidis *Tidis) SaddWithTxn(dbId uint8, txn interface{}, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) Scard

func (tidis *Tidis) Scard(dbId uint8, txn interface{}, key []byte) (uint64, error)

func (*Tidis) Sclear

func (tidis *Tidis) Sclear(dbId uint8, keys ...[]byte) (uint64, error)

func (*Tidis) SclearKeyWithTxn

func (tidis *Tidis) SclearKeyWithTxn(dbId uint8, txn1 interface{}, key []byte) (int, error)

func (*Tidis) SclearWithTxn

func (tidis *Tidis) SclearWithTxn(dbId uint8, txn interface{}, keys ...[]byte) (uint64, error)

func (*Tidis) Sdiff

func (tidis *Tidis) Sdiff(dbId uint8, txn interface{}, keys ...[]byte) ([]interface{}, error)

func (*Tidis) Sdiffstore

func (tidis *Tidis) Sdiffstore(dbId uint8, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) SdiffstoreWithTxn

func (tidis *Tidis) SdiffstoreWithTxn(dbId uint8, txn interface{}, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) Set

func (tidis *Tidis) Set(dbId uint8, txn interface{}, key, value []byte) error

func (*Tidis) SetMetaObj added in v1.0.0

func (tidis *Tidis) SetMetaObj(dbId uint8, txn, ss interface{}, key []byte) (*SetObj, bool, error)

func (*Tidis) SetMetaObjWithExpire added in v1.0.0

func (tidis *Tidis) SetMetaObjWithExpire(dbId uint8, txn, ss interface{}, key []byte, checkExpire bool) (*SetObj, bool, error)

func (*Tidis) SetWithParam

func (tidis *Tidis) SetWithParam(dbId uint8, txn interface{}, key, value []byte, msTtl uint64, nxFlag bool, xxFlag bool) (bool, error)

func (*Tidis) Setex

func (tidis *Tidis) Setex(dbId uint8, key []byte, sec int64, value []byte) error

func (*Tidis) SetexWithTxn

func (tidis *Tidis) SetexWithTxn(dbId uint8, txn interface{}, key []byte, sec int64, value []byte) error

func (*Tidis) Sinter

func (tidis *Tidis) Sinter(dbId uint8, txn interface{}, keys ...[]byte) ([]interface{}, error)

func (*Tidis) Sinterstore

func (tidis *Tidis) Sinterstore(dbId uint8, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) SinterstoreWithTxn

func (tidis *Tidis) SinterstoreWithTxn(dbId uint8, txn interface{}, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) Sismember

func (tidis *Tidis) Sismember(dbId uint8, txn interface{}, key, member []byte) (uint8, error)

func (*Tidis) Smembers

func (tidis *Tidis) Smembers(dbId uint8, txn interface{}, key []byte) ([]interface{}, error)

func (*Tidis) Sops

func (tidis *Tidis) Sops(dbId uint8, txn interface{}, opType int, keys ...[]byte) ([]interface{}, error)

func (*Tidis) SopsStore

func (tidis *Tidis) SopsStore(dbId uint8, opType int, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) SopsStoreWithTxn

func (tidis *Tidis) SopsStoreWithTxn(dbId uint8, txn interface{}, opType int, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) Srem

func (tidis *Tidis) Srem(dbId uint8, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) SremWithTxn

func (tidis *Tidis) SremWithTxn(dbId uint8, txn interface{}, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) Sunion

func (tidis *Tidis) Sunion(dbId uint8, txn interface{}, keys ...[]byte) ([]interface{}, error)

func (*Tidis) Sunionstore

func (tidis *Tidis) Sunionstore(dbId uint8, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) SunionstoreWithTxn

func (tidis *Tidis) SunionstoreWithTxn(dbId uint8, txn interface{}, dest []byte, keys ...[]byte) (uint64, error)

func (*Tidis) TenantId added in v1.0.0

func (tidis *Tidis) TenantId() string

func (*Tidis) Ttl

func (tidis *Tidis) Ttl(dbId uint8, txn interface{}, key []byte) (int64, error)

func (*Tidis) Type added in v1.0.0

func (tidis *Tidis) Type(dbId uint8, txn interface{}, key []byte) (string, error)

func (*Tidis) ZSetMetaObj added in v1.0.0

func (tidis *Tidis) ZSetMetaObj(dbId uint8, txn, ss interface{}, key []byte) (*ZSetObj, bool, error)

func (*Tidis) ZSetMetaObjWithExpire added in v1.0.0

func (tidis *Tidis) ZSetMetaObjWithExpire(dbId uint8, txn, ss interface{}, key []byte, checkExpire bool) (*ZSetObj, bool, error)

func (*Tidis) Zadd

func (tidis *Tidis) Zadd(dbId uint8, key []byte, mps ...*MemberPair) (int, error)

func (*Tidis) ZaddWithTxn

func (tidis *Tidis) ZaddWithTxn(dbId uint8, txn interface{}, key []byte, mps ...*MemberPair) (int, error)

func (*Tidis) Zcard

func (tidis *Tidis) Zcard(dbId uint8, txn interface{}, key []byte) (uint64, error)

func (*Tidis) Zcount

func (tidis *Tidis) Zcount(dbId uint8, txn interface{}, key []byte, min, max int64) (uint64, error)

func (*Tidis) Zincrby

func (tidis *Tidis) Zincrby(dbId uint8, key []byte, delta int64, member []byte) (int64, error)

func (*Tidis) ZincrbyWithTxn

func (tidis *Tidis) ZincrbyWithTxn(dbId uint8, txn interface{}, key []byte, delta int64, member []byte) (int64, error)

func (*Tidis) Zlexcount

func (tidis *Tidis) Zlexcount(dbId uint8, txn interface{}, key, start, stop []byte) (uint64, error)

func (*Tidis) Zrange

func (tidis *Tidis) Zrange(dbId uint8, txn interface{}, key []byte, start, stop int64, withscores bool, reverse bool) ([]interface{}, error)

func (*Tidis) Zrangebylex

func (tidis *Tidis) Zrangebylex(dbId uint8, txn interface{}, key []byte, start, stop []byte, offset, count int, reverse bool) ([]interface{}, error)

func (*Tidis) Zrangebyscore

func (tidis *Tidis) Zrangebyscore(dbId uint8, txn interface{}, key []byte, min, max int64, withscores bool, offset, count int, reverse bool) ([]interface{}, error)

func (*Tidis) Zrank

func (tidis *Tidis) Zrank(dbId uint8, txn interface{}, key, member []byte, score int64) (int64, bool, error)

func (*Tidis) Zrem

func (tidis *Tidis) Zrem(dbId uint8, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) ZremWithTxn

func (tidis *Tidis) ZremWithTxn(dbId uint8, txn interface{}, key []byte, members ...[]byte) (uint64, error)

func (*Tidis) Zremrangebylex

func (tidis *Tidis) Zremrangebylex(dbId uint8, key, start, stop []byte) (uint64, error)

func (*Tidis) ZremrangebylexWithTxn

func (tidis *Tidis) ZremrangebylexWithTxn(dbId uint8, txn interface{}, key, start, stop []byte) (uint64, error)

func (*Tidis) Zremrangebyscore

func (tidis *Tidis) Zremrangebyscore(dbId uint8, key []byte, min, max int64) (uint64, error)

func (*Tidis) ZremrangebyscoreWithTxn

func (tidis *Tidis) ZremrangebyscoreWithTxn(dbId uint8, txn1 interface{}, key []byte, min, max int64) (uint64, error)

func (*Tidis) Zscore

func (tidis *Tidis) Zscore(dbId uint8, txn interface{}, key, member []byte) (int64, bool, error)

type ZSetObj added in v1.0.0

type ZSetObj struct {
	Object
	Size uint64
}

func UnmarshalZSetObj added in v1.0.0

func UnmarshalZSetObj(raw []byte) (*ZSetObj, error)

Jump to

Keyboard shortcuts

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