binlog

package
v0.0.0-...-17176b1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2015 License: MIT Imports: 19 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.Static("no such list")
	ErrOutOfRange = errors.Static("index out of range")
)
View Source
var (
	ErrMetaKey = errors.Static("invalid meta key")
	ErrDataKey = errors.Static("invalid data key")

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

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

	ErrNotString = errors.Static("not string")
	ErrNotHash   = errors.Static("not hash")
	ErrNotList   = errors.Static("not list")
	ErrNotZSet   = errors.Static("not zset")
	ErrNotSet    = errors.Static("not set")
)
View Source
var (
	ErrClosed = errors.Static("binlog has been closed")
)
View Source
var (
	ErrSnapClosed = errors.Static("binlog snapshot has been closed")
)
View Source
var (
	ErrVarbytesLen = errors.Static("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 uint64) (int64, bool)

func FormatFloat

func FormatFloat(v float64) []byte

func FormatFloatString

func FormatFloatString(v float64) string

func FormatInt

func FormatInt(v int64) []byte

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 uint64) 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) (uint64, bool)

func TTLsToExpireAt

func TTLsToExpireAt(ttls int64) (uint64, bool)

Types

type Binlog

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

func New

func New(db store.Database) *Binlog

func (*Binlog) Append

func (b *Binlog) Append(db uint32, args ...interface{}) (int64, error)

APPEND key value

func (*Binlog) Close

func (b *Binlog) Close()

func (*Binlog) CompactAll

func (b *Binlog) CompactAll() error

func (*Binlog) Decr

func (b *Binlog) Decr(db uint32, args ...interface{}) (int64, error)

DECR key

func (*Binlog) DecrBy

func (b *Binlog) DecrBy(db uint32, args ...interface{}) (int64, error)

DECRBY key delta

func (*Binlog) Del

func (b *Binlog) Del(db uint32, args ...interface{}) (int64, error)

DEL key [key ...]

func (*Binlog) Dump

func (b *Binlog) Dump(db uint32, args ...interface{}) (interface{}, error)

DUMP key

func (*Binlog) Exists

func (b *Binlog) Exists(db uint32, args ...interface{}) (int64, error)

EXISTS key

func (*Binlog) Expire

func (b *Binlog) Expire(db uint32, args ...interface{}) (int64, error)

EXPIRE key seconds

func (*Binlog) ExpireAt

func (b *Binlog) ExpireAt(db uint32, args ...interface{}) (int64, error)

EXPIREAT key timestamp

func (*Binlog) Get

func (b *Binlog) Get(db uint32, args ...interface{}) ([]byte, error)

GET key

func (*Binlog) GetBit

func (b *Binlog) GetBit(db uint32, args ...interface{}) (int64, error)

GETBIT key offset

func (*Binlog) GetRange

func (b *Binlog) GetRange(db uint32, args ...interface{}) ([]byte, error)

GETRANGE key beg end

func (*Binlog) GetSet

func (b *Binlog) GetSet(db uint32, args ...interface{}) ([]byte, error)

GETSET key value

func (*Binlog) HDel

func (b *Binlog) HDel(db uint32, args ...interface{}) (int64, error)

HDEL key field [field ...]

func (*Binlog) HExists

func (b *Binlog) HExists(db uint32, args ...interface{}) (int64, error)

HEXISTS key field

func (*Binlog) HGet

func (b *Binlog) HGet(db uint32, args ...interface{}) ([]byte, error)

HGET key field

func (*Binlog) HGetAll

func (b *Binlog) HGetAll(db uint32, args ...interface{}) ([][]byte, error)

HGETALL key

func (*Binlog) HIncrBy

func (b *Binlog) HIncrBy(db uint32, args ...interface{}) (int64, error)

HINCRBY key field delta

func (*Binlog) HIncrByFloat

func (b *Binlog) HIncrByFloat(db uint32, args ...interface{}) (float64, error)

HINCRBYFLOAT key field delta

func (*Binlog) HKeys

func (b *Binlog) HKeys(db uint32, args ...interface{}) ([][]byte, error)

HKEYS key

func (*Binlog) HLen

func (b *Binlog) HLen(db uint32, args ...interface{}) (int64, error)

HLEN key

func (*Binlog) HMGet

func (b *Binlog) HMGet(db uint32, args ...interface{}) ([][]byte, error)

HMGET key field [field ...]

func (*Binlog) HMSet

func (b *Binlog) HMSet(db uint32, args ...interface{}) error

HMSET key field value [field value ...]

func (*Binlog) HSet

func (b *Binlog) HSet(db uint32, args ...interface{}) (int64, error)

HSET key field value

func (*Binlog) HSetNX

func (b *Binlog) HSetNX(db uint32, args ...interface{}) (int64, error)

HSETNX key field value

func (*Binlog) HVals

func (b *Binlog) HVals(db uint32, args ...interface{}) ([][]byte, error)

HVALS key

func (*Binlog) Incr

func (b *Binlog) Incr(db uint32, args ...interface{}) (int64, error)

INCR key

func (*Binlog) IncrBy

func (b *Binlog) IncrBy(db uint32, args ...interface{}) (int64, error)

INCRBY key delta

func (*Binlog) IncrByFloat

func (b *Binlog) IncrByFloat(db uint32, args ...interface{}) (float64, error)

INCRBYFLOAT key delta

func (*Binlog) Info

func (b *Binlog) Info() (string, error)

func (*Binlog) LIndex

func (b *Binlog) LIndex(db uint32, args ...interface{}) ([]byte, error)

LINDEX key index

func (*Binlog) LLen

func (b *Binlog) LLen(db uint32, args ...interface{}) (int64, error)

LLEN key

func (*Binlog) LPop

func (b *Binlog) LPop(db uint32, args ...interface{}) ([]byte, error)

LPOP key

func (*Binlog) LPush

func (b *Binlog) LPush(db uint32, args ...interface{}) (int64, error)

LPUSH key value [value ...]

func (*Binlog) LPushX

func (b *Binlog) LPushX(db uint32, args ...interface{}) (int64, error)

LPUSHX key value

func (*Binlog) LRange

func (b *Binlog) LRange(db uint32, args ...interface{}) ([][]byte, error)

LRANGE key beg end

func (*Binlog) LSet

func (b *Binlog) LSet(db uint32, args ...interface{}) error

LSET key index value

func (*Binlog) LTrim

func (b *Binlog) LTrim(db uint32, args ...interface{}) error

LTRIM key beg end

func (*Binlog) MGet

func (b *Binlog) MGet(db uint32, args ...interface{}) ([][]byte, error)

MGET key [key ...]

func (*Binlog) MSet

func (b *Binlog) MSet(db uint32, args ...interface{}) error

MSET key value [key value ...]

func (*Binlog) MSetNX

func (b *Binlog) MSetNX(db uint32, args ...interface{}) (int64, error)

MSETNX key value [key value ...]

func (*Binlog) NewSnapshot

func (b *Binlog) NewSnapshot() (*BinlogSnapshot, error)

func (*Binlog) PExpire

func (b *Binlog) PExpire(db uint32, args ...interface{}) (int64, error)

PEXPIRE key milliseconds

func (*Binlog) PExpireAt

func (b *Binlog) PExpireAt(db uint32, args ...interface{}) (int64, error)

PEXPIREAT key milliseconds-timestamp

func (*Binlog) PSetEX

func (b *Binlog) PSetEX(db uint32, args ...interface{}) error

PSETEX key milliseconds value

func (*Binlog) PTTL

func (b *Binlog) PTTL(db uint32, args ...interface{}) (int64, error)

PTTL key

func (*Binlog) Persist

func (b *Binlog) Persist(db uint32, args ...interface{}) (int64, error)

PERSIST key

func (*Binlog) RPop

func (b *Binlog) RPop(db uint32, args ...interface{}) ([]byte, error)

RPOP key

func (*Binlog) RPush

func (b *Binlog) RPush(db uint32, args ...interface{}) (int64, error)

RPUSH key value [value ...]

func (*Binlog) RPushX

func (b *Binlog) RPushX(db uint32, args ...interface{}) (int64, error)

RPUSHX key value

func (*Binlog) ReleaseSnapshot

func (b *Binlog) ReleaseSnapshot(sp *BinlogSnapshot)

func (*Binlog) Reset

func (b *Binlog) Reset() error

func (*Binlog) Restore

func (b *Binlog) Restore(db uint32, args ...interface{}) error

RESTORE key ttlms value

func (*Binlog) SAdd

func (b *Binlog) SAdd(db uint32, args ...interface{}) (int64, error)

SADD key member [member ...]

func (*Binlog) SCard

func (b *Binlog) SCard(db uint32, args ...interface{}) (int64, error)

SCARD key

func (*Binlog) SIsMember

func (b *Binlog) SIsMember(db uint32, args ...interface{}) (int64, error)

SISMEMBER key member

func (*Binlog) SMembers

func (b *Binlog) SMembers(db uint32, args ...interface{}) ([][]byte, error)

SMEMBERS key

func (*Binlog) SPop

func (b *Binlog) SPop(db uint32, args ...interface{}) ([]byte, error)

SPOP key

func (*Binlog) SRandMember

func (b *Binlog) SRandMember(db uint32, args ...interface{}) ([][]byte, error)

SRANDMEMBER key [count]

func (*Binlog) SRem

func (b *Binlog) SRem(db uint32, args ...interface{}) (int64, error)

SREM key member [member ...]

func (*Binlog) Set

func (b *Binlog) Set(db uint32, args ...interface{}) error

SET key value

func (*Binlog) SetBit

func (b *Binlog) SetBit(db uint32, args ...interface{}) (int64, error)

SETBIT key offset value

func (*Binlog) SetEX

func (b *Binlog) SetEX(db uint32, args ...interface{}) error

SETEX key seconds value

func (*Binlog) SetNX

func (b *Binlog) SetNX(db uint32, args ...interface{}) (int64, error)

SETNX key value

func (*Binlog) SetRange

func (b *Binlog) SetRange(db uint32, args ...interface{}) (int64, error)

SETRANGE key offset value

func (*Binlog) SlotsInfo

func (b *Binlog) SlotsInfo(db uint32, args ...interface{}) (map[uint32]int64, error)

SLOTSINFO [start] [count]

func (*Binlog) SlotsMgrtOne

func (b *Binlog) SlotsMgrtOne(db uint32, args ...interface{}) (int64, error)

SLOTSMGRTONE host port timeout key

func (*Binlog) SlotsMgrtSlot

func (b *Binlog) SlotsMgrtSlot(db uint32, args ...interface{}) (int64, error)

SLOTSMGRTSLOT host port timeout slot

func (*Binlog) SlotsMgrtTagOne

func (b *Binlog) SlotsMgrtTagOne(db uint32, args ...interface{}) (int64, error)

SLOTSMGRTTAGONE host port timeout key

func (*Binlog) SlotsMgrtTagSlot

func (b *Binlog) SlotsMgrtTagSlot(db uint32, args ...interface{}) (int64, error)

SLOTSMGRTTAGSLOT host port timeout slot

func (*Binlog) SlotsRestore

func (b *Binlog) SlotsRestore(db uint32, args ...interface{}) error

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

func (*Binlog) Strlen

func (b *Binlog) Strlen(db uint32, args ...interface{}) (int64, error)

STRLEN key

func (*Binlog) TTL

func (b *Binlog) TTL(db uint32, args ...interface{}) (int64, error)

TTL key

func (*Binlog) Type

func (b *Binlog) Type(db uint32, args ...interface{}) (ObjectCode, error)

TYPE key

func (*Binlog) ZAdd

func (b *Binlog) ZAdd(db uint32, args ...interface{}) (int64, error)

ZADD key score member [score member ...]

func (*Binlog) ZCard

func (b *Binlog) ZCard(db uint32, args ...interface{}) (int64, error)

ZCARD key

func (*Binlog) ZGetAll

func (b *Binlog) ZGetAll(db uint32, args ...interface{}) ([][]byte, error)

ZGETALL key

func (*Binlog) ZIncrBy

func (b *Binlog) ZIncrBy(db uint32, args ...interface{}) (float64, error)

ZINCRBY key delta member

func (*Binlog) ZRem

func (b *Binlog) ZRem(db uint32, args ...interface{}) (int64, error)

ZREM key member [member ...]

func (*Binlog) ZScore

func (b *Binlog) ZScore(db uint32, args ...interface{}) (float64, bool, error)

ZSCORE key member

type BinlogSnapshot

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

func (*BinlogSnapshot) Close

func (s *BinlogSnapshot) Close()

func (*BinlogSnapshot) LoadObjCron

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

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) 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) 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 []interface{}
}

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

Jump to

Keyboard shortcuts

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