store

package
v0.0.0-...-70285c8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaCode = byte('#')
	DataCode = byte('&')
)
View Source
const (
	MaxExpireAt = 1e15
)
View Source
const (
	MaxSlotNum = 1024
)

Variables

View Source
var (
	ErrNoSuchList = errors.New("no such list")
	ErrOutOfRange = errors.New("index out of range")
)
View Source
var (
	ErrMetaKey = errors.New("invalid meta key")
	ErrDataKey = errors.New("invalid data key")

	ErrNotMatched = errors.New("unmatched raw bytes")

	ErrObjectCode  = errors.New("invalid object code")
	ErrObjectValue = errors.New("invalid object value")

	ErrNotString = errors.New("not string")
	ErrNotHash   = errors.New("not hash")
	ErrNotList   = errors.New("not list")
	ErrNotZSet   = errors.New("not zset")
	ErrNotSet    = errors.New("not set")
)
View Source
var (
	ErrClosed = errors.New("store has been closed")
)
View Source
var (
	ErrSnapClosed = errors.New("store snapshot has been closed")
)
View Source
var (
	ErrVarbytesLen = errors.New("invalid varbytes length")
)

Functions

func DecodeMetaKey

func DecodeMetaKey(p []byte) (db uint32, key []byte, err error)

func EncodeDataKeyPrefix

func EncodeDataKeyPrefix(db uint32, key []byte) []byte

func EncodeMetaKey

func EncodeMetaKey(db uint32, key []byte) []byte

func EncodeMetaKeyPrefixSlot

func EncodeMetaKeyPrefixSlot(db uint32, slot uint32) []byte

func EncodeMetaKeyPrefixTag

func EncodeMetaKeyPrefixTag(db uint32, tag []byte) []byte

func ExpireAtToTTLms

func ExpireAtToTTLms(expireat int64) (int64, bool)

func FormatByte

func FormatByte(arg interface{}) []byte

func FormatBytes

func FormatBytes(args ...interface{}) [][]byte

func FormatFloat

func FormatFloat(v float64) []byte

func FormatFloatString

func FormatFloatString(v float64) string

func FormatInt

func FormatInt(v int64) []byte

func FormatString

func FormatString(i interface{}) string

func FormatUint

func FormatUint(u uint64) []byte

func HashKeyToSlot

func HashKeyToSlot(key []byte) ([]byte, uint32)

func HashTag

func HashTag(key []byte) []byte

func HashTagToSlot

func HashTagToSlot(tag []byte) uint32

func IsExpired

func IsExpired(expireat int64) bool

func Num64

func Num64(i interface{}) interface{}

func ParseFloat

func ParseFloat(i interface{}) (float64, error)

func ParseInt

func ParseInt(i interface{}) (int64, error)

func ParseUint

func ParseUint(i interface{}) (uint64, error)

func TTLmsToExpireAt

func TTLmsToExpireAt(ttlms int64) (int64, bool)

func TTLsToExpireAt

func TTLsToExpireAt(ttls int64) (int64, bool)

Types

type BufReader

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

func NewBufReader

func NewBufReader(p []byte) *BufReader

func (*BufReader) Len

func (r *BufReader) Len() int

func (*BufReader) ReadByte

func (r *BufReader) ReadByte() (byte, error)

func (*BufReader) ReadBytes

func (r *BufReader) ReadBytes(n int) ([]byte, error)

func (*BufReader) ReadFloat64

func (r *BufReader) ReadFloat64() (float64, error)

func (*BufReader) ReadInt64

func (r *BufReader) ReadInt64() (int64, error)

func (*BufReader) ReadUint64

func (r *BufReader) ReadUint64() (uint64, error)

func (*BufReader) ReadUvarint

func (r *BufReader) ReadUvarint() (uint64, error)

func (*BufReader) ReadVarbytes

func (r *BufReader) ReadVarbytes() ([]byte, error)

func (*BufReader) ReadVarint

func (r *BufReader) ReadVarint() (int64, error)

type BufWriter

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

func NewBufWriter

func NewBufWriter(p []byte) *BufWriter

func (*BufWriter) Bytes

func (w *BufWriter) Bytes() []byte

func (*BufWriter) Len

func (w *BufWriter) Len() int

func (*BufWriter) WriteByte

func (w *BufWriter) WriteByte(b byte) error

func (*BufWriter) WriteBytes

func (w *BufWriter) WriteBytes(p []byte) error

func (*BufWriter) WriteFloat64

func (w *BufWriter) WriteFloat64(f float64) error

func (*BufWriter) WriteInt64

func (w *BufWriter) WriteInt64(s int64) error

func (*BufWriter) WriteUint64

func (w *BufWriter) WriteUint64(s uint64) error

func (*BufWriter) WriteUvarint

func (w *BufWriter) WriteUvarint(v uint64) error

func (*BufWriter) WriteVarbytes

func (w *BufWriter) WriteVarbytes(p []byte) error

func (*BufWriter) WriteVarint

func (w *BufWriter) WriteVarint(v int64) error

type Forward

type Forward struct {
	DB   uint32
	Op   string
	Args [][]byte
}

type ForwardHandler

type ForwardHandler func(f *Forward) error

type ObjectCode

type ObjectCode byte
const (
	StringCode ObjectCode = 'K'
	HashCode   ObjectCode = 'H'
	ListCode   ObjectCode = 'L'
	ZSetCode   ObjectCode = 'Z'
	SetCode    ObjectCode = 'S'
)

func (ObjectCode) String

func (c ObjectCode) String() string

type Store

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

func New

func New(db engine.Database) *Store

func (*Store) Acquire

func (s *Store) Acquire() error

func (*Store) Append

func (s *Store) Append(db uint32, args [][]byte) (int64, error)

APPEND key value

func (*Store) Close

func (s *Store) Close()

func (*Store) CompactAll

func (s *Store) CompactAll() error

func (*Store) Decr

func (s *Store) Decr(db uint32, args [][]byte) (int64, error)

DECR key

func (*Store) DecrBy

func (s *Store) DecrBy(db uint32, args [][]byte) (int64, error)

DECRBY key delta

func (*Store) Del

func (s *Store) Del(db uint32, args [][]byte) (int64, error)

DEL key [key ...]

func (*Store) Dump

func (s *Store) Dump(db uint32, args [][]byte) (interface{}, error)

DUMP key

func (*Store) Exists

func (s *Store) Exists(db uint32, args [][]byte) (int64, error)

EXISTS key

func (*Store) Expire

func (s *Store) Expire(db uint32, args [][]byte) (int64, error)

EXPIRE key seconds

func (*Store) ExpireAt

func (s *Store) ExpireAt(db uint32, args [][]byte) (int64, error)

EXPIREAT key timestamp

func (*Store) Get

func (s *Store) Get(db uint32, args [][]byte) ([]byte, error)

GET key

func (*Store) GetBit

func (s *Store) GetBit(db uint32, args [][]byte) (int64, error)

GETBIT key offset

func (*Store) GetRange

func (s *Store) GetRange(db uint32, args [][]byte) ([]byte, error)

GETRANGE key beg end

func (*Store) GetSet

func (s *Store) GetSet(db uint32, args [][]byte) ([]byte, error)

GETSET key value

func (*Store) HDel

func (s *Store) HDel(db uint32, args [][]byte) (int64, error)

HDEL key field [field ...]

func (*Store) HExists

func (s *Store) HExists(db uint32, args [][]byte) (int64, error)

HEXISTS key field

func (*Store) HGet

func (s *Store) HGet(db uint32, args [][]byte) ([]byte, error)

HGET key field

func (*Store) HGetAll

func (s *Store) HGetAll(db uint32, args [][]byte) ([][]byte, error)

HGETALL key

func (*Store) HIncrBy

func (s *Store) HIncrBy(db uint32, args [][]byte) (int64, error)

HINCRBY key field delta

func (*Store) HIncrByFloat

func (s *Store) HIncrByFloat(db uint32, args [][]byte) (float64, error)

HINCRBYFLOAT key field delta

func (*Store) HKeys

func (s *Store) HKeys(db uint32, args [][]byte) ([][]byte, error)

HKEYS key

func (*Store) HLen

func (s *Store) HLen(db uint32, args [][]byte) (int64, error)

HLEN key

func (*Store) HMGet

func (s *Store) HMGet(db uint32, args [][]byte) ([][]byte, error)

HMGET key field [field ...]

func (*Store) HMSet

func (s *Store) HMSet(db uint32, args [][]byte) error

HMSET key field value [field value ...]

func (*Store) HSet

func (s *Store) HSet(db uint32, args [][]byte) (int64, error)

HSET key field value

func (*Store) HSetNX

func (s *Store) HSetNX(db uint32, args [][]byte) (int64, error)

HSETNX key field value

func (*Store) HVals

func (s *Store) HVals(db uint32, args [][]byte) ([][]byte, error)

HVALS key

func (*Store) Incr

func (s *Store) Incr(db uint32, args [][]byte) (int64, error)

INCR key

func (*Store) IncrBy

func (s *Store) IncrBy(db uint32, args [][]byte) (int64, error)

INCRBY key delta

func (*Store) IncrByFloat

func (s *Store) IncrByFloat(db uint32, args [][]byte) (float64, error)

INCRBYFLOAT key delta

func (*Store) Info

func (s *Store) Info() (string, error)

func (*Store) LIndex

func (s *Store) LIndex(db uint32, args [][]byte) ([]byte, error)

LINDEX key index

func (*Store) LLen

func (s *Store) LLen(db uint32, args [][]byte) (int64, error)

LLEN key

func (*Store) LPop

func (s *Store) LPop(db uint32, args [][]byte) ([]byte, error)

LPOP key

func (*Store) LPush

func (s *Store) LPush(db uint32, args [][]byte) (int64, error)

LPUSH key value [value ...]

func (*Store) LPushX

func (s *Store) LPushX(db uint32, args [][]byte) (int64, error)

LPUSHX key value

func (*Store) LRange

func (s *Store) LRange(db uint32, args [][]byte) ([][]byte, error)

LRANGE key beg end

func (*Store) LSet

func (s *Store) LSet(db uint32, args [][]byte) error

LSET key index value

func (*Store) LTrim

func (s *Store) LTrim(db uint32, args [][]byte) error

LTRIM key beg end

func (*Store) MGet

func (s *Store) MGet(db uint32, args [][]byte) ([][]byte, error)

MGET key [key ...]

func (*Store) MSet

func (s *Store) MSet(db uint32, args [][]byte) error

MSET key value [key value ...]

func (*Store) MSetNX

func (s *Store) MSetNX(db uint32, args [][]byte) (int64, error)

MSETNX key value [key value ...]

func (*Store) NewSnapshot

func (s *Store) NewSnapshot() (*StoreSnapshot, error)

func (*Store) NewSnapshotFunc

func (s *Store) NewSnapshotFunc(f func()) (*StoreSnapshot, error)

New a snapshot and then call f if not nil

func (*Store) PExpire

func (s *Store) PExpire(db uint32, args [][]byte) (int64, error)

PEXPIRE key milliseconds

func (*Store) PExpireAt

func (s *Store) PExpireAt(db uint32, args [][]byte) (int64, error)

PEXPIREAT key milliseconds-timestamp

func (*Store) PSetEX

func (s *Store) PSetEX(db uint32, args [][]byte) error

PSETEX key milliseconds value

func (*Store) PTTL

func (s *Store) PTTL(db uint32, args [][]byte) (int64, error)

PTTL key

func (*Store) Persist

func (s *Store) Persist(db uint32, args [][]byte) (int64, error)

PERSIST key

func (*Store) RPop

func (s *Store) RPop(db uint32, args [][]byte) ([]byte, error)

RPOP key

func (*Store) RPush

func (s *Store) RPush(db uint32, args [][]byte) (int64, error)

RPUSH key value [value ...]

func (*Store) RPushX

func (s *Store) RPushX(db uint32, args [][]byte) (int64, error)

RPUSHX key value

func (*Store) RegPostCommitHandler

func (s *Store) RegPostCommitHandler(h ForwardHandler)

Register the handler that will be called after db storage committed

func (*Store) RegPreCommitHandler

func (s *Store) RegPreCommitHandler(h ForwardHandler)

Register the handler that will be called before db storage commit

func (*Store) Release

func (s *Store) Release()

func (*Store) ReleaseSnapshot

func (s *Store) ReleaseSnapshot(sp *StoreSnapshot)

func (*Store) Reset

func (s *Store) Reset() error

func (*Store) Restore

func (s *Store) Restore(db uint32, args [][]byte) error

RESTORE key ttlms value

func (*Store) SAdd

func (s *Store) SAdd(db uint32, args [][]byte) (int64, error)

SADD key member [member ...]

func (*Store) SCard

func (s *Store) SCard(db uint32, args [][]byte) (int64, error)

SCARD key

func (*Store) SIsMember

func (s *Store) SIsMember(db uint32, args [][]byte) (int64, error)

SISMEMBER key member

func (*Store) SMembers

func (s *Store) SMembers(db uint32, args [][]byte) ([][]byte, error)

SMEMBERS key

func (*Store) SPop

func (s *Store) SPop(db uint32, args [][]byte) ([]byte, error)

SPOP key

func (*Store) SRandMember

func (s *Store) SRandMember(db uint32, args [][]byte) ([][]byte, error)

SRANDMEMBER key [count]

func (*Store) SRem

func (s *Store) SRem(db uint32, args [][]byte) (int64, error)

SREM key member [member ...]

func (*Store) Set

func (s *Store) Set(db uint32, args [][]byte) error

SET key value

func (*Store) SetBit

func (s *Store) SetBit(db uint32, args [][]byte) (int64, error)

SETBIT key offset value

func (*Store) SetEX

func (s *Store) SetEX(db uint32, args [][]byte) error

SETEX key seconds value

func (*Store) SetNX

func (s *Store) SetNX(db uint32, args [][]byte) (int64, error)

SETNX key value

func (*Store) SetRange

func (s *Store) SetRange(db uint32, args [][]byte) (int64, error)

SETRANGE key offset value

func (*Store) SlotsInfo

func (s *Store) SlotsInfo(db uint32, args [][]byte) (map[uint32]int64, error)

SLOTSINFO [start] [count]

func (*Store) SlotsMgrtOne

func (s *Store) SlotsMgrtOne(db uint32, args [][]byte) (int64, error)

SLOTSMGRTONE host port timeout key

func (*Store) SlotsMgrtSlot

func (s *Store) SlotsMgrtSlot(db uint32, args [][]byte) (int64, error)

SLOTSMGRTSLOT host port timeout slot

func (*Store) SlotsMgrtTagOne

func (s *Store) SlotsMgrtTagOne(db uint32, args [][]byte) (int64, error)

SLOTSMGRTTAGONE host port timeout key

func (*Store) SlotsMgrtTagSlot

func (s *Store) SlotsMgrtTagSlot(db uint32, args [][]byte) (int64, error)

SLOTSMGRTTAGSLOT host port timeout slot

func (*Store) SlotsRestore

func (s *Store) SlotsRestore(db uint32, args [][]byte) error

SLOTSRESTORE key ttlms value [key ttlms value ...]

func (*Store) Strlen

func (s *Store) Strlen(db uint32, args [][]byte) (int64, error)

STRLEN key

func (*Store) TTL

func (s *Store) TTL(db uint32, args [][]byte) (int64, error)

TTL key

func (*Store) Type

func (s *Store) Type(db uint32, args [][]byte) (ObjectCode, error)

TYPE key

func (*Store) ZAdd

func (s *Store) ZAdd(db uint32, args [][]byte) (int64, error)

ZADD key score member [score member ...]

func (*Store) ZCard

func (s *Store) ZCard(db uint32, args [][]byte) (int64, error)

ZCARD key

func (*Store) ZCount

func (s *Store) ZCount(db uint32, args [][]byte) (int64, error)

ZCOUNT key min max

func (*Store) ZGetAll

func (s *Store) ZGetAll(db uint32, args [][]byte) ([][]byte, error)

ZGETALL key

func (*Store) ZIncrBy

func (s *Store) ZIncrBy(db uint32, args [][]byte) (float64, error)

ZINCRBY key delta member

func (*Store) ZLexCount

func (s *Store) ZLexCount(db uint32, args [][]byte) (int64, error)

ZLEXCOUNT key min max

func (*Store) ZRange

func (s *Store) ZRange(db uint32, args [][]byte) ([][]byte, error)

ZRANGE key start stop [WITHSCORES]

func (*Store) ZRangeByLex

func (s *Store) ZRangeByLex(db uint32, args [][]byte) ([][]byte, error)

ZRANGEBYLEX key min max [LIMIT offset count]

func (*Store) ZRangeByScore

func (s *Store) ZRangeByScore(db uint32, args [][]byte) ([][]byte, error)

ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

func (*Store) ZRank

func (s *Store) ZRank(db uint32, args [][]byte) (int64, error)

ZRANK key member

func (*Store) ZRem

func (s *Store) ZRem(db uint32, args [][]byte) (int64, error)

ZREM key member [member ...]

func (*Store) ZRemRangeByLex

func (s *Store) ZRemRangeByLex(db uint32, args [][]byte) (int64, error)

ZREMRANGEBYLEX key min max

func (*Store) ZRemRangeByRank

func (s *Store) ZRemRangeByRank(db uint32, args [][]byte) (int64, error)

ZREMRANGEBYRANK key start stop

func (*Store) ZRemRangeByScore

func (s *Store) ZRemRangeByScore(db uint32, args [][]byte) (int64, error)

ZREMRANGEBYSCORE key min max

func (*Store) ZRevRange

func (s *Store) ZRevRange(db uint32, args [][]byte) ([][]byte, error)

ZREVRANGE key start stop [WITHSCORES]

func (*Store) ZRevRangeByLex

func (s *Store) ZRevRangeByLex(db uint32, args [][]byte) ([][]byte, error)

ZRevRANGEBYLEX key min max [LIMIT offset count]

func (*Store) ZRevRangeByScore

func (s *Store) ZRevRangeByScore(db uint32, args [][]byte) ([][]byte, error)

ZREVRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

func (*Store) ZRevRank

func (s *Store) ZRevRank(db uint32, args [][]byte) (int64, error)

ZREVRANK key member

func (*Store) ZScore

func (s *Store) ZScore(db uint32, args [][]byte) (float64, bool, error)

ZSCORE key member

type StoreSnapshot

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

func (*StoreSnapshot) Close

func (s *StoreSnapshot) Close()

func (*StoreSnapshot) LoadObjCron

func (s *StoreSnapshot) LoadObjCron(wait time.Duration, ncpu, step int) ([]*rdb.ObjEntry, bool, error)

Jump to

Keyboard shortcuts

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