Documentation ¶
Index ¶
- Constants
- Variables
- func AddDBExpKeyStats(store *Storager, stats *DBStats, mk, tk []byte, exp int64)
- func AddDBKeyCn(store *Storager, stats *DBStats, key []byte)
- func DBHasKey(s *Storager, index int) bool
- func HashTag(key []byte) []byte
- func InitAllDbStats(s *Storager)
- func Int64(v []byte, err error) (int64, error)
- func MaxInt32(a int32, b int32) int32
- func MinInt32(a int32, b int32) int32
- func PutInt64(v int64) []byte
- func RemoveDBExpKeyStats(store *Storager, stats *DBStats, mk, tk []byte, exp int64)
- func RemoveDBKeyCn(store *Storager, stats *DBStats, key []byte)
- func Uint64(v []byte, err error) (uint64, error)
- type Batch
- type DB
- func (m *DB) Close() (err error)
- func (m *DB) DBBitmap() driver.IBitmapCmd
- func (m *DB) DBHash() driver.IHashCmd
- func (m *DB) DBList() driver.IListCmd
- func (m *DB) DBSet() driver.ISetCmd
- func (m *DB) DBSlot() driver.ISlotsCmd
- func (m *DB) DBString() driver.IStringCmd
- func (m *DB) DBZSet() driver.IZsetCmd
- func (m *DB) DelKeyMeta(t *Batch, key []byte, dataType byte)
- func (db *DB) FlushDB(ctx context.Context) (drop int64, err error)
- func (db *DB) Index() int
- func (db *DB) IndexVarBuf() []byte
- func (db *DB) SetIndex(index int)
- func (m *DB) SetKeyMeta(t *Batch, key []byte, dataType byte)
- type DBBitmap
- func (db *DBBitmap) BitCount(ctx context.Context, key []byte, start int, end int) (int64, error)
- func (db *DBBitmap) BitOP(ctx context.Context, op string, destKey []byte, srcKeys ...[]byte) (int64, error)
- func (db *DBBitmap) BitPos(ctx context.Context, key []byte, on int, start int, end int) (int64, error)
- func (db *DBBitmap) GetBit(ctx context.Context, key []byte, offset int) (int64, error)
- func (db *DBBitmap) SetBit(ctx context.Context, key []byte, offset int, on int) (int64, error)
- type DBHash
- func (db *DBHash) BatchDel(ctx context.Context, t *Batch, keys ...[]byte) (int64, error)
- func (db *DBHash) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
- func (db *DBHash) BatchHMset(ctx context.Context, t *Batch, key []byte, args ...driver.FVPair) error
- func (db *DBHash) Clear(ctx context.Context, key []byte) (int64, error)
- func (db *DBHash) Del(ctx context.Context, keys ...[]byte) (int64, error)
- func (db *DBHash) Dump(ctx context.Context, key []byte) (binVal []byte, err error)
- func (db *DBHash) Exists(ctx context.Context, key []byte) (int64, error)
- func (db *DBHash) Expire(ctx context.Context, key []byte, duration int64) (int64, error)
- func (db *DBHash) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error)
- func (db *DBHash) HDel(ctx context.Context, key []byte, args ...[]byte) (int64, error)
- func (db *DBHash) HGet(ctx context.Context, key []byte, field []byte) ([]byte, error)
- func (db *DBHash) HGetAll(ctx context.Context, key []byte) ([]driver.FVPair, error)
- func (db *DBHash) HIncrBy(ctx context.Context, key []byte, field []byte, delta int64) (int64, error)
- func (db *DBHash) HKeys(ctx context.Context, key []byte) ([][]byte, error)
- func (db *DBHash) HLen(ctx context.Context, key []byte) (int64, error)
- func (db *DBHash) HMget(ctx context.Context, key []byte, args ...[]byte) ([][]byte, error)
- func (db *DBHash) HMset(ctx context.Context, key []byte, args ...driver.FVPair) error
- func (db *DBHash) HSet(ctx context.Context, key []byte, field []byte, value []byte) (int64, error)
- func (db *DBHash) HValues(ctx context.Context, key []byte) ([][]byte, error)
- func (db *DBHash) Persist(ctx context.Context, key []byte) (int64, error)
- func (db *DBHash) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.Hash) (err error)
- func (db *DBHash) TTL(ctx context.Context, key []byte) (int64, error)
- type DBList
- func (db *DBList) BLPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error)
- func (db *DBList) BRPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error)
- func (db *DBList) BatchDel(ctx context.Context, t *Batch, keys ...[]byte) (int64, error)
- func (db *DBList) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
- func (db *DBList) BatchRPush(ctx context.Context, t *Batch, key []byte, args ...[]byte) (int64, error)
- func (db *DBList) Del(ctx context.Context, keys ...[]byte) (int64, error)
- func (db *DBList) Dump(ctx context.Context, key []byte) (binVal []byte, err error)
- func (db *DBList) Exists(ctx context.Context, key []byte) (int64, error)
- func (db *DBList) Expire(ctx context.Context, key []byte, duration int64) (int64, error)
- func (db *DBList) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error)
- func (db *DBList) LIndex(ctx context.Context, key []byte, index int32) ([]byte, error)
- func (db *DBList) LLen(ctx context.Context, key []byte) (int64, error)
- func (db *DBList) LPop(ctx context.Context, key []byte) ([]byte, error)
- func (db *DBList) LPush(ctx context.Context, key []byte, args ...[]byte) (int64, error)
- func (db *DBList) LRange(ctx context.Context, key []byte, start int32, stop int32) ([][]byte, error)
- func (db *DBList) LSet(ctx context.Context, key []byte, index int32, value []byte) error
- func (db *DBList) LTrim(ctx context.Context, key []byte, start, stop int64) error
- func (db *DBList) LTrimBack(ctx context.Context, key []byte, trimSize int32) (int32, error)
- func (db *DBList) LTrimFront(ctx context.Context, key []byte, trimSize int32) (int32, error)
- func (db *DBList) Persist(ctx context.Context, key []byte) (int64, error)
- func (db *DBList) RPop(ctx context.Context, key []byte) ([]byte, error)
- func (db *DBList) RPush(ctx context.Context, key []byte, args ...[]byte) (int64, error)
- func (db *DBList) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.List) (err error)
- func (db *DBList) TTL(ctx context.Context, key []byte) (int64, error)
- type DBSet
- func (db *DBSet) BatchDel(ctx context.Context, t *Batch, keys ...[]byte) (int64, error)
- func (db *DBSet) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
- func (db *DBSet) BatchSAdd(ctx context.Context, t *Batch, key []byte, args ...[]byte) (int64, error)
- func (db *DBSet) Del(ctx context.Context, keys ...[]byte) (int64, error)
- func (db *DBSet) Dump(ctx context.Context, key []byte) (binVal []byte, err error)
- func (db *DBSet) Exists(ctx context.Context, key []byte) (int64, error)
- func (db *DBSet) Expire(ctx context.Context, key []byte, duration int64) (int64, error)
- func (db *DBSet) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error)
- func (db *DBSet) Persist(ctx context.Context, key []byte) (int64, error)
- func (db *DBSet) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.Set) (err error)
- func (db *DBSet) SAdd(ctx context.Context, key []byte, args ...[]byte) (int64, error)
- func (db *DBSet) SCard(ctx context.Context, key []byte) (int64, error)
- func (db *DBSet) SDiff(ctx context.Context, keys ...[]byte) ([][]byte, error)
- func (db *DBSet) SDiffStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error)
- func (db *DBSet) SInter(ctx context.Context, keys ...[]byte) ([][]byte, error)
- func (db *DBSet) SInterStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error)
- func (db *DBSet) SIsMember(ctx context.Context, key []byte, member []byte) (int64, error)
- func (db *DBSet) SKeyExists(ctx context.Context, key []byte) (int64, error)
- func (db *DBSet) SMembers(ctx context.Context, key []byte) ([][]byte, error)
- func (db *DBSet) SRem(ctx context.Context, key []byte, args ...[]byte) (int64, error)
- func (db *DBSet) SUnion(ctx context.Context, keys ...[]byte) ([][]byte, error)
- func (db *DBSet) SUnionStore(ctx context.Context, dstKey []byte, keys ...[]byte) (int64, error)
- func (db *DBSet) TTL(ctx context.Context, key []byte) (int64, error)
- type DBSlot
- func (m *DBSlot) BatchDel(ctx context.Context, keys ...*MetaObjKey) (num int64, err error)
- func (m *DBSlot) Dump(ctx context.Context, key *MetaObjKey) (binVal []byte, err error)
- func (m *DBSlot) HashKeyToSlot(key []byte) ([]byte, uint32)
- func (m *DBSlot) HashTagToSlot(tag []byte) uint32
- func (m *DBSlot) MigrateKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, key []byte) (migrateCn int64, err error)
- func (m *DBSlot) MigrateOneKey(ctx context.Context, addr string, timeout time.Duration, key []byte) (migrateCn int64, err error)
- func (m *DBSlot) MigrateSlotKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, slot uint64) (migrateCn int64, err error)
- func (m *DBSlot) MigrateSlotOneKey(ctx context.Context, addr string, timeout time.Duration, slot uint64) (migrateCn int64, err error)
- func (m *DBSlot) SlotsCheck(ctx context.Context) (err error)
- func (m *DBSlot) SlotsDel(ctx context.Context, slots ...uint64) (slotInfos []*driver.SlotInfo, err error)
- func (m *DBSlot) SlotsHashKey(ctx context.Context, keys ...[]byte) ([]uint64, error)
- func (m *DBSlot) SlotsInfo(ctx context.Context, startSlot, count uint64, withSize bool) (slotInfos []*driver.SlotInfo, err error)
- func (m *DBSlot) SlotsRestore(ctx context.Context, objs ...*driver.SlotsRestoreObj) (err error)
- func (m *DBSlot) TTL(ctx context.Context, key *MetaObjKey) (int64, error)
- type DBStats
- type DBString
- func (db *DBString) Append(ctx context.Context, key []byte, value []byte) (int64, error)
- func (db *DBString) BatchDel(ctx context.Context, t *Batch, keys ...[]byte) (int64, error)
- func (db *DBString) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
- func (db *DBString) BatchSet(ctx context.Context, t *Batch, key []byte, value []byte) error
- func (db *DBString) Decr(ctx context.Context, key []byte) (int64, error)
- func (db *DBString) DecrBy(ctx context.Context, key []byte, decrement int64) (int64, error)
- func (db *DBString) Del(ctx context.Context, keys ...[]byte) (int64, error)
- func (db *DBString) Dump(ctx context.Context, key []byte) (binVal []byte, err error)
- func (db *DBString) Exists(ctx context.Context, key []byte) (int64, error)
- func (db *DBString) Expire(ctx context.Context, key []byte, duration int64) (int64, error)
- func (db *DBString) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error)
- func (db *DBString) Get(ctx context.Context, key []byte) ([]byte, error)
- func (db *DBString) GetRange(ctx context.Context, key []byte, start int, end int) ([]byte, error)
- func (db *DBString) GetSet(ctx context.Context, key []byte, value []byte) ([]byte, error)
- func (db *DBString) GetSlice(ctx context.Context, key []byte) (openkvDriver.ISlice, error)
- func (db *DBString) Incr(ctx context.Context, key []byte) (int64, error)
- func (db *DBString) IncrBy(ctx context.Context, key []byte, increment int64) (int64, error)
- func (db *DBString) MGet(ctx context.Context, keys ...[]byte) ([][]byte, error)
- func (db *DBString) MSet(ctx context.Context, args ...driver.KVPair) error
- func (db *DBString) Persist(ctx context.Context, key []byte) (int64, error)
- func (db *DBString) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.String) (err error)
- func (db *DBString) Set(ctx context.Context, key []byte, value []byte) error
- func (db *DBString) SetEX(ctx context.Context, key []byte, duration int64, value []byte) error
- func (db *DBString) SetNX(ctx context.Context, key []byte, value []byte) (n int64, err error)
- func (db *DBString) SetNXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error)
- func (db *DBString) SetRange(ctx context.Context, key []byte, offset int, value []byte) (int64, error)
- func (db *DBString) SetXXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error)
- func (db *DBString) StrLen(ctx context.Context, key []byte) (int64, error)
- func (db *DBString) TTL(ctx context.Context, key []byte) (int64, error)
- type DBZSet
- func (db *DBZSet) BatchDel(ctx context.Context, t *Batch, keys ...[]byte) (int64, error)
- func (db *DBZSet) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
- func (db *DBZSet) BatchZAdd(ctx context.Context, t *Batch, key []byte, args ...driver.ScorePair) (int64, error)
- func (db *DBZSet) Del(ctx context.Context, keys ...[]byte) (int64, error)
- func (db *DBZSet) Dump(ctx context.Context, key []byte) (binVal []byte, err error)
- func (db *DBZSet) Exists(ctx context.Context, key []byte) (int64, error)
- func (db *DBZSet) Expire(ctx context.Context, key []byte, duration int64) (int64, error)
- func (db *DBZSet) ExpireAt(ctx context.Context, key []byte, when int64) (int64, error)
- func (db *DBZSet) Persist(ctx context.Context, key []byte) (int64, error)
- func (db *DBZSet) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.ZSet) (err error)
- func (db *DBZSet) TTL(ctx context.Context, key []byte) (int64, error)
- func (db *DBZSet) ZAdd(ctx context.Context, key []byte, args ...driver.ScorePair) (int64, error)
- func (db *DBZSet) ZCard(ctx context.Context, key []byte) (int64, error)
- func (db *DBZSet) ZCount(ctx context.Context, key []byte, min int64, max int64) (int64, error)
- func (db *DBZSet) ZIncrBy(ctx context.Context, key []byte, delta int64, member []byte) (int64, error)
- func (db *DBZSet) ZInterStore(ctx context.Context, destKey []byte, srcKeys [][]byte, weights []int64, ...) (int64, error)
- func (db *DBZSet) ZLexCount(ctx context.Context, key []byte, min []byte, max []byte, ...) (int64, error)
- func (db *DBZSet) ZRange(ctx context.Context, key []byte, start int, stop int) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, ...) ([][]byte, error)
- func (db *DBZSet) ZRangeByScore(ctx context.Context, key []byte, min int64, max int64, offset int, count int) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRangeByScoreGeneric(ctx context.Context, key []byte, min int64, max int64, offset int, count int, ...) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRangeGeneric(ctx context.Context, key []byte, start int, stop int, reverse bool) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRank(ctx context.Context, key []byte, member []byte) (int64, error)
- func (db *DBZSet) ZRem(ctx context.Context, key []byte, members ...[]byte) (int64, error)
- func (db *DBZSet) ZRemRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, ...) (int64, error)
- func (db *DBZSet) ZRemRangeByRank(ctx context.Context, key []byte, start int, stop int) (int64, error)
- func (db *DBZSet) ZRemRangeByScore(ctx context.Context, key []byte, min int64, max int64) (int64, error)
- func (db *DBZSet) ZRevRange(ctx context.Context, key []byte, start int, stop int) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRevRangeByScore(ctx context.Context, key []byte, min int64, max int64, offset int, count int) ([]driver.ScorePair, error)
- func (db *DBZSet) ZRevRank(ctx context.Context, key []byte, member []byte) (int64, error)
- func (db *DBZSet) ZScore(ctx context.Context, key []byte, member []byte) (int64, error)
- func (db *DBZSet) ZUnionStore(ctx context.Context, destKey []byte, srcKeys [][]byte, weights []int64, ...) (int64, error)
- type DataType
- type MetaObjKey
- type MigrateAsyncTask
- type SnapshotHead
- type Storager
- func (m *Storager) Close() (err error)
- func (s *Storager) ExistKeyDB() (info []driver.InfoPair)
- func (m *Storager) FlushAll(ctx context.Context) error
- func (s *Storager) GetCommitLock() *sync.Mutex
- func (s *Storager) GetKVStore() storagerDriver.IKV
- func (s *Storager) GetRWLock() *sync.RWMutex
- func (m *Storager) InitOpts(opts *config.StorgerOptions)
- func (s *Storager) KeySpaceStatsInfo() (info []driver.InfoPair)
- func (m *Storager) Name() string
- func (store *Storager) Open(ctx context.Context) (err error)
- func (s *Storager) RecoverFromSnapshotWithHead(ctx context.Context, r io.Reader) (h *SnapshotHead, err error)
- func (s *Storager) SaveSnapshotWithHead(ctx context.Context, h *SnapshotHead, w io.Writer) (err error)
- func (m *Storager) Select(ctx context.Context, index int) (idb driver.IDB, err error)
- func (s *Storager) SetCommitter(committer storagerDriver.ICommitter)
- func (s *Storager) StatsInfo(sections ...string) (info map[string][]driver.InfoPair)
- type TTLChecker
Constants ¶
const ( // max allowed databases MaxDatabases int = 10240 // max key size MaxKeySize int = 1024 // max hash field size MaxHashFieldSize int = 1024 // max zset member size MaxZSetMemberSize int = 1024 // max set member size MaxSetMemberSize int = 1024 // max value size MaxValueSize int = 1024 * 1024 * 1024 // default scan count DefaultScanCount int = 10 )
For different const size configuration
const ( StringName = "STRING" ListName = "LIST" HashName = "HASH" SetName = "SET" ZSetName = "ZSET" BitmapName = "BITMAP" )
For different type name
const ( NoneType byte = iota StringType HSizeType HashType LMetaType ListType SSizeType SetType ZSizeType ZSetType ZScoreType ExpTimeType ExpMetaType BitmapType )
for backend store key notice: Please add new type in order
const ( UnionType byte = 51 DiffType byte = 52 InterType byte = 53 )
For set op
const ( MinScore int64 = math.MinInt64 + 1 MaxScore int64 = math.MaxInt64 InvalidScore int64 = math.MinInt64 AggregateSum = "sum" AggregateMin = "min" AggregateMax = "max" )
For zset op
const ( BitAND = "and" BitOR = "or" BitXOR = "xor" BitNot = "not" )
For bit operation
const ( MaxVarintLen16 = 3 MaxVarintLen32 = 5 // the most size for varint is 10 bytes MaxVarintLen64 = 10 )
MaxVarintLenN is the maximum length of a varint-encoded N-bit integer.
const ( CodeTypeMeta byte = '@' CodeTypeData byte = '$' Version byte = 0 )
const (
RegisterStoragerName = "xdis-storager"
)
Variables ¶
var ( ErrValueIntOutOfRange = errors.New("ERR value is not an integer or out of range") ErrIntNumber = errors.New("ERR invalid integer") ErrKeySize = errors.New("ERR invalid key size") ErrValueSize = errors.New("ERR invalid value size") ErrExpireValue = errors.New("ERR invalid expire value") ErrStringKey = errors.New("ERR invalid encode string key") ErrLMetaKey = errors.New("ERR invalid lmeta key") ErrListKey = errors.New("ERR invalid list key") ErrListSeq = errors.New("ERR invalid list sequence, overflow") ErrListIndex = errors.New("ERR invalid list index") ErrHashKey = errors.New("ERR invalid hash key") ErrHashIntVal = errors.New("ERR hash value is not an integer") ErrHSizeKey = errors.New("ERR invalid hsize key") ErrHashFieldSize = errors.New("ERR invalid hash field size") ErrSetKey = errors.New("ERR invalid set key") ErrSSizeKey = errors.New("ERR invalid ssize key") ErrSetMemberSize = errors.New("ERR invalid set member size") ErrZSizeKey = errors.New("ERR invalid zsize key") ErrZSetKey = errors.New("ERR invalid zset key") ErrZScoreKey = errors.New("ERR invalid zscore key") ErrScoreOverflow = errors.New("ERR zset score overflow") ErrInvalidAggregate = errors.New("ERR invalid aggregate") ErrInvalidWeightNum = errors.New("ERR invalid weight number") ErrInvalidSrcKeyNum = errors.New("ERR invalid src key number") ErrZSetMemberSize = errors.New("ERR invalid zset member size") ErrExpMetaKey = errors.New("ERR invalid expire meta key") ErrExpTimeKey = errors.New("ERR invalid expire time key") ErrDataType = errors.New("ERR invalid data type") ErrMetaKey = errors.New("ERR invalid meta key") ErrBitmapKey = errors.New("ERR invalid encode bitmap key") // For different common errors ErrScoreMiss = errors.New("ERR zset score miss") // For slots ErrUnsupportSlots = errors.New("unsupport slots") ErrKeyNotFound = errors.New("key not found") )
var TypeName = map[byte]string{ StringType: "string", HashType: "hash", HSizeType: "hsize", ListType: "list", LMetaType: "lmeta", SetType: "set", SSizeType: "ssize", ZSetType: "zset", ZSizeType: "zsize", ZScoreType: "zscore", ExpTimeType: "exptime", ExpMetaType: "expmeta", BitmapType: "bitmap", }
TypeName is the map of type -> name
Functions ¶
func AddDBExpKeyStats ¶
func AddDBKeyCn ¶
func InitAllDbStats ¶
func InitAllDbStats(s *Storager)
InitDbStats begin init db stats load to map after storager open
func RemoveDBExpKeyStats ¶
func RemoveDBKeyCn ¶
Types ¶
type Batch ¶
type Batch struct { *openkv.WriteBatch sync.Locker // contains filtered or unexported fields }
Batch write batch commit
type DB ¶
DB core sturct impl like redis string, list, hash, set, zset, bitmap struct store db op
func (*DB) DBBitmap ¶
func (m *DB) DBBitmap() driver.IBitmapCmd
func (*DB) DBString ¶
func (m *DB) DBString() driver.IStringCmd
func (*DB) IndexVarBuf ¶
IndexVarBuf gets the index varint buf of database.
type DBBitmap ¶
type DBBitmap struct { *DB // contains filtered or unexported fields }
func NewDBBitmap ¶
func (*DBBitmap) BitOP ¶
func (db *DBBitmap) BitOP(ctx context.Context, op string, destKey []byte, srcKeys ...[]byte) (int64, error)
BitOP does the bit operations in data.
func (*DBBitmap) BitPos ¶
func (db *DBBitmap) BitPos(ctx context.Context, key []byte, on int, start int, end int) (int64, error)
BitPos returns the pos of the data.
type DBHash ¶
type DBHash struct { *DB // contains filtered or unexported fields }
func (*DBHash) BatchExpire ¶
func (db *DBHash) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
BatchExpire expires the data with duration.
func (*DBHash) BatchHMset ¶
func (db *DBHash) BatchHMset(ctx context.Context, t *Batch, key []byte, args ...driver.FVPair) error
BatchHMset sets multi field-values.
func (*DBHash) HIncrBy ¶
func (db *DBHash) HIncrBy(ctx context.Context, key []byte, field []byte, delta int64) (int64, error)
HIncrBy increases the value of field by delta.
type DBList ¶
type DBList struct { *DB // contains filtered or unexported fields }
func (*DBList) BLPop ¶
func (db *DBList) BLPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error)
BLPop pops the list with block way.
func (*DBList) BRPop ¶
func (db *DBList) BRPop(ctx context.Context, keys [][]byte, timeout time.Duration) ([]interface{}, error)
BRPop bpops the list with block way.
func (*DBList) BatchExpire ¶
func (*DBList) BatchRPush ¶
func (db *DBList) BatchRPush(ctx context.Context, t *Batch, key []byte, args ...[]byte) (int64, error)
BatchRPush rpushs the value .
func (*DBList) LRange ¶
func (db *DBList) LRange(ctx context.Context, key []byte, start int32, stop int32) ([][]byte, error)
LRange gets the value of list at range.
func (*DBList) LTrimFront ¶
LTrimFront trims the value from top.
type DBSet ¶
type DBSet struct { *DB // contains filtered or unexported fields }
func (*DBSet) BatchExpire ¶
func (db *DBSet) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
BatchExpire expires the set.
func (*DBSet) BatchSAdd ¶
func (db *DBSet) BatchSAdd(ctx context.Context, t *Batch, key []byte, args ...[]byte) (int64, error)
BatchSAdd adds the value to the set.
func (*DBSet) Restore ¶
func (db *DBSet) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.Set) (err error)
Restore set rdb
func (*DBSet) SDiffStore ¶
SDiffStore gets the different of sets and stores to dest set.
func (*DBSet) SInterStore ¶
SInterStore intersects the sets and stores to dest set.
func (*DBSet) SKeyExists ¶
SKeyExists checks whether set existed or not.
func (*DBSet) SUnionStore ¶
SUnionStore unions the sets and stores to the dest set.
type DBSlot ¶
type DBSlot struct { *DB // contains filtered or unexported fields }
func (*DBSlot) HashTagToSlot ¶
func (*DBSlot) MigrateKeyWithSameTag ¶
func (m *DBSlot) MigrateKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, key []byte) (migrateCn int64, err error)
MigrateKeyWithSameTag migrate keys/vals which have the same tag with one key to addr with timeout (ms) return n, n migrate success, 0 slot is empty
func (*DBSlot) MigrateOneKey ¶
func (m *DBSlot) MigrateOneKey(ctx context.Context, addr string, timeout time.Duration, key []byte) (migrateCn int64, err error)
MigrateOneKey migrate one key/val (no hash tag tag=key) to addr with timeout (ms) return n (same key, diff dataType), success, 0 slot is empty
func (*DBSlot) MigrateSlotKeyWithSameTag ¶
func (m *DBSlot) MigrateSlotKeyWithSameTag(ctx context.Context, addr string, timeout time.Duration, slot uint64) (migrateCn int64, err error)
MigrateSlotKeyWithSameTag migrate slot keys/vals which have the same tag with one key to addr with timeout (ms) return n, success, 0 slot is empty
func (*DBSlot) MigrateSlotOneKey ¶
func (m *DBSlot) MigrateSlotOneKey(ctx context.Context, addr string, timeout time.Duration, slot uint64) (migrateCn int64, err error)
MigrateSlotOneKey migrate slot one key/val to addr with timeout (ms) return 1, success, 0 slot is empty
func (*DBSlot) SlotsCheck ¶
SlotsCheck slots must check below case - The key stored in each slot can find the corresponding val in the db - Keys in each db can be found in the corresponding slot WARNING: just used debug/test, don't use in product,
func (*DBSlot) SlotsDel ¶
func (m *DBSlot) SlotsDel(ctx context.Context, slots ...uint64) (slotInfos []*driver.SlotInfo, err error)
SlotsDel del slots, return after del slot info just del slot one key if slot have key to del, slotInfo.Size is 1, else is 0
func (*DBSlot) SlotsHashKey ¶
SlotsHashKey hash keys to slots, return slot slice
func (*DBSlot) SlotsInfo ¶
func (m *DBSlot) SlotsInfo(ctx context.Context, startSlot, count uint64, withSize bool) (slotInfos []*driver.SlotInfo, err error)
SlotsInfo show slot info with slots range [start,start+count] return slotInfo slice if withSize is true, slotInfo.Size is slot's keys cn; size>0,show it; else exits key is 1, show it
func (*DBSlot) SlotsRestore ¶
SlotsRestore dest migrate addr restore slot obj [key ttlms serialized-value(rdb) ...]
type DBStats ¶
type DBStats struct { KeyCn atomic.Int64 ExpireKeyCn atomic.Int64 TotalExpireTime atomic.Int64 TotalExpireCn atomic.Int64 }
func GetDbStats ¶
func LoadDbStats ¶
type DBString ¶
type DBString struct { *DB // contains filtered or unexported fields }
func NewDBString ¶
func (*DBString) BatchExpire ¶
func (db *DBString) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
BatchExpire expires the data.
func (*DBString) Restore ¶
func (db *DBString) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.String) (err error)
Restore string rdb
func (*DBString) SetNXEX ¶
func (db *DBString) SetNXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error)
SetNXEX set k v nx ex seconds NX -- Only set the key if it does not already exist. EX seconds -- Set the specified expire time, in seconds.
func (*DBString) SetRange ¶
func (db *DBString) SetRange(ctx context.Context, key []byte, offset int, value []byte) (int64, error)
SetRange sets the data with new value from offset.
func (*DBString) SetXXEX ¶
func (db *DBString) SetXXEX(ctx context.Context, key []byte, duration int64, value []byte) (n int64, err error)
SetXXEX set k v xx ex seconds XX -- Only set the key if it already exists. EX seconds -- Set the specified expire time, in seconds.
type DBZSet ¶
type DBZSet struct { *DB // contains filtered or unexported fields }
func (*DBZSet) BatchExpire ¶
func (db *DBZSet) BatchExpire(ctx context.Context, t *Batch, key []byte, duration int64) (int64, error)
BatchExpire expires the zset.
func (*DBZSet) BatchZAdd ¶
func (db *DBZSet) BatchZAdd(ctx context.Context, t *Batch, key []byte, args ...driver.ScorePair) (int64, error)
BatchZAdd add the members.
func (*DBZSet) Restore ¶
func (db *DBZSet) Restore(ctx context.Context, t *Batch, key []byte, ttl int64, val rdb.ZSet) (err error)
Restore zset rdb use int64 for zset score, not float
func (*DBZSet) ZIncrBy ¶
func (db *DBZSet) ZIncrBy(ctx context.Context, key []byte, delta int64, member []byte) (int64, error)
ZIncrBy increases the score of member with delta.
func (*DBZSet) ZInterStore ¶
func (db *DBZSet) ZInterStore(ctx context.Context, destKey []byte, srcKeys [][]byte, weights []int64, aggregate []byte) (int64, error)
ZInterStore intersects the zsets and stores to dest zset.
func (*DBZSet) ZLexCount ¶
func (db *DBZSet) ZLexCount(ctx context.Context, key []byte, min []byte, max []byte, rangeType driver.RangeType) (int64, error)
ZLexCount gets the count of zset lexicographically.
func (*DBZSet) ZRange ¶
func (db *DBZSet) ZRange(ctx context.Context, key []byte, start int, stop int) ([]driver.ScorePair, error)
ZRange gets the members from start to stop.
func (*DBZSet) ZRangeByLex ¶
func (db *DBZSet) ZRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, rangeType driver.RangeType, offset int, count int) ([][]byte, error)
ZRangeByLex scans the zset lexicographically
func (*DBZSet) ZRangeByScore ¶
func (db *DBZSet) ZRangeByScore(ctx context.Context, key []byte, min int64, max int64, offset int, count int) ([]driver.ScorePair, error)
ZRangeByScore gets the data with score in min and max. min and max must be inclusive if no limit, set offset = 0 and count = -1
func (*DBZSet) ZRangeByScoreGeneric ¶
func (db *DBZSet) ZRangeByScoreGeneric(ctx context.Context, key []byte, min int64, max int64, offset int, count int, reverse bool) ([]driver.ScorePair, error)
ZRangeByScoreGeneric is a generic function to scan zset with score. min and max must be inclusive if no limit, set offset = 0 and count<0
func (*DBZSet) ZRangeGeneric ¶
func (db *DBZSet) ZRangeGeneric(ctx context.Context, key []byte, start int, stop int, reverse bool) ([]driver.ScorePair, error)
ZRangeGeneric is a generic function for scan zset. zrange/zrevrange index pos start,stop
func (*DBZSet) ZRemRangeByLex ¶
func (db *DBZSet) ZRemRangeByLex(ctx context.Context, key []byte, min []byte, max []byte, rangeType driver.RangeType) (int64, error)
ZRemRangeByLex remvoes members in [min, max] lexicographically
func (*DBZSet) ZRemRangeByRank ¶
func (db *DBZSet) ZRemRangeByRank(ctx context.Context, key []byte, start int, stop int) (int64, error)
ZRemRangeByRank removes the member at range from start to stop.
func (*DBZSet) ZRemRangeByScore ¶
func (db *DBZSet) ZRemRangeByScore(ctx context.Context, key []byte, min int64, max int64) (int64, error)
ZRemRangeByScore removes the data with score at [min, max]
func (*DBZSet) ZRevRange ¶
func (db *DBZSet) ZRevRange(ctx context.Context, key []byte, start int, stop int) ([]driver.ScorePair, error)
ZRevRange gets the data reversed.
func (*DBZSet) ZRevRangeByScore ¶
func (db *DBZSet) ZRevRangeByScore(ctx context.Context, key []byte, min int64, max int64, offset int, count int) ([]driver.ScorePair, error)
ZRevRangeByScore gets the data with score at [min, max] min and max must be inclusive if no limit, set offset = 0 and count = -1
type MetaObjKey ¶
type MigrateAsyncTask ¶
type MigrateAsyncTask struct { Ctx context.Context DBSlot *DBSlot Cli *redis.Client Keys []*MetaObjKey }
func (*MigrateAsyncTask) Run ¶
func (m *MigrateAsyncTask) Run() (err error)
type SnapshotHead ¶
type SnapshotHead struct {
CommitID uint64
}
SnapshotHead is the head of a snapshot.
type Storager ¶
type Storager struct {
// contains filtered or unexported fields
}
Storager core store struct for server use like redis
func New ¶
func New(opts *config.StorgerOptions) (store *Storager)
func (*Storager) ExistKeyDB ¶
func (*Storager) GetCommitLock ¶
GetCommitLock noCopy return mutex lock for commit log/data
func (*Storager) GetKVStore ¶
func (s *Storager) GetKVStore() storagerDriver.IKV
GetKVStore get kvstore engine which save data
func (*Storager) InitOpts ¶
func (m *Storager) InitOpts(opts *config.StorgerOptions)
func (*Storager) KeySpaceStatsInfo ¶
func (*Storager) RecoverFromSnapshotWithHead ¶
func (s *Storager) RecoverFromSnapshotWithHead(ctx context.Context, r io.Reader) (h *SnapshotHead, err error)
RecoverFromSnapshotWithHead clears all data and loads dump file to db return snapshot head info,error
func (*Storager) SaveSnapshotWithHead ¶
func (s *Storager) SaveSnapshotWithHead(ctx context.Context, h *SnapshotHead, w io.Writer) (err error)
SaveSnapshotWithHead dumps data to the Writer with SnapshotHead
func (*Storager) SetCommitter ¶
func (s *Storager) SetCommitter(committer storagerDriver.ICommitter)
SetCommitter
type TTLChecker ¶
func NewTTLChecker ¶
func NewTTLChecker(db *DB) *TTLChecker