Documentation
¶
Overview ¶
Package crc64 implements the Jones coefficients with an init value of 0.
Thanks to github.com/cupcake/rdb for providing an early version of deocde
Index ¶
- Variables
- func Digest(b []byte) uint64
- func MultiBulkBytes(val Value) ([]byte, int)
- func New() hash.Hash64
- type ByteReader
- type Command
- type CommandType
- type Decoder
- type ErrProtocol
- type Nop
- func (d Nop) Aux(key, value []byte)
- func (d Nop) BeginDatabase(n int)
- func (d Nop) BeginHash(key []byte, length, expiry int64)
- func (d Nop) BeginList(key []byte, length, expiry int64)
- func (d Nop) BeginRDB()
- func (d Nop) BeginSet(key []byte, cardinality, expiry int64)
- func (d Nop) BeginStream(key []byte, cardinality, expiry int64)
- func (d Nop) BeginZSet(key []byte, cardinality, expiry int64)
- func (d Nop) EndDatabase(n int)
- func (d Nop) EndHash(key []byte)
- func (d Nop) EndList(key []byte)
- func (d Nop) EndRDB()
- func (d Nop) EndSet(key []byte)
- func (d Nop) EndStream(key []byte)
- func (d Nop) EndZSet(key []byte)
- func (d Nop) Hset(key, field, value []byte)
- func (d Nop) ResizeDatabase(dbSize, expiresSize uint32)
- func (d Nop) Rpush(key, value []byte)
- func (d Nop) Sadd(key, member []byte)
- func (d Nop) Set(key, value []byte, expiry int64)
- func (d Nop) Xadd(key, id, listpack []byte)
- func (d Nop) Zadd(key []byte, score float64, member []byte)
- type Outer
- type Reader
- type Replication
- type Type
- type Value
- func AnyValue(v interface{}) Value
- func ArrayValue(vals []Value) Value
- func BoolValue(t bool) Value
- func BytesValue(b []byte) Value
- func ErrorValue(err error) Value
- func FloatValue(f float64) Value
- func IntegerValue(i int) Value
- func MultiBulkValue(commandName string, args ...interface{}) Value
- func NullValue() Value
- func SimpleStringValue(s string) Value
- func StringValue(s string) Value
- func (v Value) Array() []Value
- func (v Value) Bool() bool
- func (v Value) Bytes() []byte
- func (v Value) Equals(value Value) bool
- func (v Value) Error() error
- func (v Value) Float() float64
- func (v Value) Integer() int
- func (v Value) IsNull() bool
- func (v Value) MarshalRESP() ([]byte, error)
- func (v Value) ReplInfo() (runID string, offset int64)
- func (v Value) String() string
- func (v Value) Type() Type
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var ( CommandTypeMap = map[string]CommandType{ "ping": Ping, "select": Select, "zadd": Zadd, "sadd": Sadd, "zrem": Zrem, "del": Delete, "lpush": Lpush, "lpushx": LpushX, "rpush": Rpush, "rpushx": RpushX, "rpop": Rpop, "rpoplpush": RpopLpush, "lpop": Lpop, "zremrangebylex": ZremRangeByLex, "zremrangebyrank": ZremRangeByRank, "zremrangebyscore": ZremRangeByScore, "zunionstore": ZunionStore, "zincrby": ZincrBy, "sdiffstore": SdiffStore, "sinterstore": SinterStore, "smove": Smove, "sunionstore": SunionStore, "srem": Srem, "set": Set, "setbit": SetBit, "append": Append, "bitfield": BitField, "bitop": BitOp, "decr": Decr, "decrby": DecrBy, "incr": Incr, "incrby": IncrBy, "incrbyfloat": IncrByFloat, "getset": GetSet, "mset": Mset, "msetnx": MsetNX, "setex": SetEX, "setnx": SetNX, "setrange": SetRange, "blpop": BlPop, "brpop": BrPop, "brpoplpush": BrPopLpush, "linsert": Linsert, "lrem": Lrem, "lset": Lset, "ltrim": Ltrim, "expire": Expire, "expireat": ExpireAt, "pexpire": Pexpire, "pexpireat": PexpireAt, "move": Move, "persist": Persist, "rename": Rename, "restore": Restore, "hset": Hset, "hsetnx": HsetNx, "hmset": HmSet, "hincrby": HincrBy, "hincrbyfloat": HincrByFloat, "pfadd": PfAdd, "pfmerge": PfMerge, "psetx": PsetX, } CommandNameMap = map[CommandType]string{ Ping: "ping", Select: "select", Zadd: "zadd", Sadd: "sadd", Zrem: "zrem", Delete: "del", Lpush: "lpush", LpushX: "lpushx", Rpush: "rpush", RpushX: "rpushx", Rpop: "rpop", RpopLpush: "rpoplpush", Lpop: "lpop", ZremRangeByLex: "zremrangebylex", ZremRangeByRank: "zremrangebyrank", ZremRangeByScore: "zremrangebyscore", ZunionStore: "zunionstore", ZincrBy: "zincrby", SdiffStore: "sdiffstore", SinterStore: "sinterstore", Smove: "smove", SunionStore: "sunionstore", Srem: "srem", Set: "set", SetBit: "setbit", Append: "append", BitField: "bitfield", BitOp: "bitop", Decr: "decr", DecrBy: "decrby", Incr: "incr", IncrBy: "incrby", IncrByFloat: "incrbyfloat", GetSet: "getset", Mset: "mset", MsetNX: "msetnx", SetEX: "setex", SetNX: "setnx", SetRange: "setrange", BlPop: "blpop", BrPop: "brpop", BrPopLpush: "brpoplpush", Linsert: "linsert", Lrem: "lrem", Lset: "lset", Ltrim: "ltrim", Expire: "expire", ExpireAt: "expireat", Pexpire: "pexpire", PexpireAt: "pexpireat", Move: "move", Persist: "persist", Rename: "rename", Restore: "restore", Hset: "hset", HsetNx: "hsetnx", HmSet: "hmset", HincrBy: "hincrby", HincrByFloat: "hincrbyfloat", PfAdd: "pfadd", PfMerge: "pfmerge", PsetX: "psetx", } )
var NilValue = Value{Null: true}
var OKReply = "OK"
Functions ¶
func MultiBulkBytes ¶
Types ¶
type ByteReader ¶
type ByteReader interface { io.Reader // io.ByteReader io.ByteScanner }
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command all the command combinations
func NewCommand ¶
func NewCommand(cmdType CommandType, args ...[]byte) Command
type CommandType ¶
type CommandType string
const ( RDB CommandType = "rdb" Ping CommandType = "ping" Pong CommandType = "pong" Ok CommandType = "ok" Err CommandType = "err" Empty CommandType = "empty" Undefined CommandType = "undefined" Select CommandType = "select" Zadd CommandType = "zadd" Sadd CommandType = "sadd" Zrem CommandType = "zrem" Delete CommandType = "delete" Lpush CommandType = "lpush" LpushX CommandType = "lpushx" Rpush CommandType = "rpush" RpushX CommandType = "rpushx" Rpop CommandType = "rpop" RpopLpush CommandType = "rpoplpush" Lpop CommandType = "lpop" ZremRangeByLex CommandType = "zremrangebylex" ZremRangeByRank CommandType = "zremrangebyrank" ZremRangeByScore CommandType = "zremrangebyscore" ZunionStore CommandType = "zunionstore" ZincrBy CommandType = "zincrby" SdiffStore CommandType = "sdiffstore" SinterStore CommandType = "sinterstore" Smove CommandType = "smove" SunionStore CommandType = "sunionstore" Srem CommandType = "srem" Set CommandType = "set" SetBit CommandType = "setbit" Append CommandType = "append" BitField CommandType = "bitfield" BitOp CommandType = "bitop" Decr CommandType = "decr" DecrBy CommandType = "decrby" Incr CommandType = "incr" IncrBy CommandType = "incrby" IncrByFloat CommandType = "incrbyfloat" GetSet CommandType = "getset" Mset CommandType = "mset" MsetNX CommandType = "msetnx" SetEX CommandType = "setex" SetNX CommandType = "setnx" SetRange CommandType = "setrange" BlPop CommandType = "blpop" BrPop CommandType = "brpop" BrPopLpush CommandType = "brpoplpush" Linsert CommandType = "linsert" Lrem CommandType = "lrem" Lset CommandType = "lset" Ltrim CommandType = "ltrim" Expire CommandType = "expire" ExpireAt CommandType = "expireat" Pexpire CommandType = "pexpire" PexpireAt CommandType = "pexpireat" Move CommandType = "move" Persist CommandType = "persist" Rename CommandType = "rename" Restore CommandType = "restore" Hset CommandType = "hset" HsetNx CommandType = "hsetnx" HmSet CommandType = "hmset" HincrBy CommandType = "hincrby" HincrByFloat CommandType = "hincrbyfloat" PfAdd CommandType = "pfadd" PfMerge CommandType = "pfmerge" PsetX CommandType = "psetx" )
type Decoder ¶
type Decoder interface { // BeginDatabase is called when database n Begins. // Once a database Begins, another database will not Begin until EndDatabase is called. BeginDatabase(n int) // Set is called once for each string key. Set(key, value []byte, expiry int64) // BeginHash is called at the beginning of a hash. // Hset will be called exactly length times before EndHash. BeginHash(key []byte, length, expiry int64) // Hset is called once for each field=value pair in a hash. Hset(key, field, value []byte) // EndHash is called when there are no more fields in a hash. EndHash(key []byte) // BeginSet is called at the beginning of a set. // Sadd will be called exactly cardinality times before EndSet. BeginSet(key []byte, cardinality, expiry int64) // Sadd is called once for each member of a set. Sadd(key, member []byte) // EndSet is called when there are no more fields in a set. EndSet(key []byte) // BeginStream is called at the beginning of a stream. // Xadd will be called exactly length times before EndStream. BeginStream(key []byte, cardinality, expiry int64) // Xadd is called once for each id in a stream. Xadd(key, streamID, listpack []byte) // EndHash is called when there are no more fields in a hash. EndStream(key []byte) // BeginList is called at the beginning of a list. // Rpush will be called exactly length times before EndList. // If length of the list is not known, then length is -1 BeginList(key []byte, length, expiry int64) // Rpush is called once for each value in a list. Rpush(key, value []byte) // EndList is called when there are no more values in a list. EndList(key []byte) // BeginZSet is called at the beginning of a sorted set. // Zadd will be called exactly cardinality times before EndZSet. BeginZSet(key []byte, cardinality, expiry int64) // Zadd is called once for each member of a sorted set. Zadd(key []byte, score float64, member []byte) // EndZSet is called when there are no more members in a sorted set. EndZSet(key []byte) // EndDatabase is called at the end of a database. EndDatabase(n int) // BeginRDB is called when parsing of a valid RDB file Begins. BeginRDB() // EndRDB is called when parsing of the RDB file is complete. EndRDB() // AUX field Aux(key, value []byte) // ResizeDB hint ResizeDatabase(dbSize, expiresSize uint32) }
A Decodr must be implemented to parse a RDB io.Reader & parse a command io.Reader
type ErrProtocol ¶
type ErrProtocol struct{ Msg string }
func (ErrProtocol) Error ¶
func (err ErrProtocol) Error() string
type Nop ¶
type Nop struct{}
Nop may be embedded in a real Decoder to avoid implementing methods.
func (Nop) BeginDatabase ¶
func (Nop) BeginStream ¶
func (Nop) EndDatabase ¶
func (Nop) ResizeDatabase ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a specialized RESP Value type reader.
func (*Reader) ReadMultiBulk ¶
ReadMultiBulk reads the next multi bulk Value from Reader. A multi bulk value is a RESP ArrayV that contains one or more bulk strings. For more information on RESP arrays and strings please see http://redis.io/topics/protocol.
type Replication ¶
type Replication struct {
// contains filtered or unexported fields
}
func NewReplication ¶
func NewReplication(t tp.Topologist, stge io.Writer, out Outer) *Replication
func (*Replication) Start ¶
func (r *Replication) Start() (func(), error)
type Value ¶
Value represents the data of a valid RESP type.
func AnyValue ¶
func AnyValue(v interface{}) Value
AnyValue returns a RESP value from an interface. This function infers the types. Arrays are not allowed.
func BytesValue ¶
BytesValue returns a RESP bulk string. A bulk string can represent any data.
func FloatValue ¶
FloatValue returns a RESP bulk string representation of a float.
func MultiBulkValue ¶
MultiBulkValue returns a RESP array which contains one or more bulk strings. For more information on RESP arrays and strings please see http://redis.io/topics/protocol.
func SimpleStringValue ¶
SimpleStringValue returns a RESP simple string. A simple string has no new lines. The carriage return and new line characters are replaced with spaces.
func StringValue ¶
StringValue returns a RESP bulk string. A bulk string can represent any data.
func (Value) Array ¶
Array converts the Value to a an array. If Value is not an array or when it's is a RESP Null value, nil is returned.
func (Value) Bool ¶
Bool converts Value to an bool. If Value cannot be converted, false is returned.
func (Value) Bytes ¶
Bytes converts the Value to a byte array. An empty string is converted to a non-nil empty byte array. If it's a RESP Null value, nil is returned.
func (Value) Error ¶
Error converts the Value to an error. If Value is not an error, nil is returned.
func (Value) Float ¶
Float converts Value to a float64. If Value cannot be converted Zero is returned.
func (Value) Integer ¶
Integer converts Value to an int. If Value cannot be converted, Zero is returned.
func (Value) MarshalRESP ¶
MarshalRESP returns the original serialized byte representation of Value. For more information on this format please see http://redis.io/topics/protocol.
type ValueType ¶
type ValueType byte
ValueType of redis type
const ( TypeString ValueType = 0 TypeList ValueType = 1 TypeSet ValueType = 2 TypeZSet ValueType = 3 TypeHash ValueType = 4 TypeZSet2 ValueType = 5 TypeModule ValueType = 6 TypeModule2 ValueType = 7 TypeHashZipmap ValueType = 9 TypeListZiplist ValueType = 10 TypeSetIntset ValueType = 11 TypeZSetZiplist ValueType = 12 TypeHashZiplist ValueType = 13 TypeListQuicklist ValueType = 14 TypeStreamListPacks ValueType = 15 )
type value