Documentation ¶
Index ¶
- Constants
- Variables
- func CmdParamsErr(cmd string) error
- func ExtractHashTag(key string) []byte
- func Int64(reply interface{}, err error) (int64, error)
- func InterfaceByte(items [][]byte) []interface{}
- func InterfaceByteSubKeys(key []byte, fields [][]byte) []interface{}
- func InterfaceString(items []string) []interface{}
- func LowerSlice(buf []byte) []byte
- func PackArgs(items ...interface{}) (args []interface{})
- func ParseSetArgs(args [][]byte) (e ExpireType, t int64, c SetCondition, err error)
- func Register(name string, f CommandFunc)
- func StringSlice(b [][]byte) []string
- func UpperSlice(buf []byte) []byte
- type Cmd
- type CommandFunc
- type Error
- type ExpireType
- type InternalServerConn
- type RespReader
- type RespWriter
- func (w *RespWriter) Flush()
- func (w *RespWriter) WriteArray(lst []interface{})
- func (w *RespWriter) WriteBulk(b []byte)
- func (w *RespWriter) WriteBulkFrom(n int64, rb io.Reader)
- func (w *RespWriter) WriteError(err error)
- func (w *RespWriter) WriteFVPairArray(lst [][]byte)
- func (w *RespWriter) WriteInteger(n int64)
- func (w *RespWriter) WriteScorePairArray(lst [][]byte, withScores bool)
- func (w *RespWriter) WriteSliceArray(lst [][]byte)
- func (w *RespWriter) WriteStatus(status string)
- type Session
- func (s *Session) Close()
- func (s *Session) DoAuth() error
- func (s *Session) GetTxClients() map[int]*InternalServerConn
- func (s *Session) IsAdmin() bool
- func (s *Session) Perform(startUnixNano int64) error
- func (s *Session) ReleaseTxClients()
- func (s *Session) ResetTx()
- func (s *Session) SendTxQueued(err error) error
- func (s *Session) SetAuth(authEnabled bool, userPassword, adminPassword string)
- func (s *Session) SetLastQueryTime()
- func (s *Session) SetQueryProperty(v bool)
- func (s *Session) SetReadDeadline()
- func (s *Session) SetTxCancel(err error)
- func (s *Session) SetTxClients(clients map[int]*InternalServerConn)
- type SessionManager
- type SetCondition
- type TxCommandServerMap
- type TxRecorder
Constants ¶
View Source
const ( INFO string = "INFO" COMMAND string = "COMMAND" PING string = "PING" PONG string = "PONG" ECHO string = "ECHO" TYPE string = "TYPE" AUTH string = "AUTH" SHUTDOWN string = "SHUTDOWN" PKSETEXAT string = "PKSETEXAT" SET string = "SET" SETEX string = "SETEX" PSETEX string = "PSETEX" SETNX string = "SETNX" MSET string = "MSET" DEL string = "DEL" GET string = "GET" GETSET string = "GETSET" MGET string = "MGET" INCR string = "INCR" INCRBY string = "INCRBY" INCRBYFLOAT string = "INCRBYFLOAT" DECR string = "DECR" DECRBY string = "DECRBY" EXISTS string = "EXISTS" EXPIRE string = "EXPIRE" EXPIREAT string = "EXPIREAT" PEXPIRE string = "PEXPIRE" PEXPIREAT string = "PEXPIREAT" TTL string = "TTL" PTTL string = "PTTL" PERSIST string = "PERSIST" UNLINK string = "UNLINK" SELECT string = "SELECT" KDEL string = "KDEL" KTTL string = "KTTL" KEXISTS string = "KEXISTS" KEXPIRE string = "KEXPIRE" KPERSIST string = "KPERSIST" KEXPIREAT string = "KEXPIREAT" APPEND string = "APPEND" GETRANGE string = "GETRANGE" SETRANGE string = "SETRANGE" STRLEN string = "STRLEN" BITCOUNT string = "BITCOUNT" BITPOS string = "BITPOS" GETBIT string = "GETBIT" SETBIT string = "SETBIT" HSET string = "HSET" HMSET string = "HMSET" HGET string = "HGET" HMGET string = "HMGET" HEXISTS string = "HEXISTS" HLEN string = "HLEN" HKEYS string = "HKEYS" HVALS string = "HVALS" HDEL string = "HDEL" HINCRBY string = "HINCRBY" HGETALL string = "HGETALL" HSCAN string = "HSCAN" HCLEAR string = "HCLEAR" HEXPIRE string = "HEXPIRE" HEXPIREAT string = "HEXPIREAT" HTTL string = "HTTL" HPERSIST string = "HPERSIST" HKEYEXISTS string = "HKEYEXISTS" SADD string = "SADD" SREM string = "SREM" SPOP string = "SPOP" SCARD string = "SCARD" SISMEMBER string = "SISMEMBER" SMEMBERS string = "SMEMBERS" SSCAN string = "SSCAN" SRANDMEMBER string = "SRANDMEMBER" SCLEAR string = "SCLEAR" SEXPIRE string = "SEXPIRE" SEXPIREAT string = "SEXPIREAT" STTL string = "STTL" SPERSIST string = "SPERSIST" SKEYEXISTS string = "SKEYEXISTS" ZADD string = "ZADD" ZSCORE string = "ZSCORE" ZCARD string = "ZCARD" ZCOUNT string = "ZCOUNT" ZINCRBY string = "ZINCRBY" ZRANGE string = "ZRANGE" ZRANGEBYSCORE string = "ZRANGEBYSCORE" ZREVRANGEBYSCORE string = "ZREVRANGEBYSCORE" ZRANK string = "ZRANK" ZREM string = "ZREM" ZREMRANGEBYRANK string = "ZREMRANGEBYRANK" ZREMRANGEBYSCORE string = "ZREMRANGEBYSCORE" ZREVRANGE string = "ZREVRANGE" ZREVRANK string = "ZREVRANK" ZREMRANGEBYLEX string = "ZREMRANGEBYLEX" ZLEXCOUNT string = "ZLEXCOUNT" ZSCAN string = "ZSCAN" ZCLEAR string = "ZCLEAR" ZEXPIRE string = "ZEXPIRE" ZEXPIREAT string = "ZEXPIREAT" ZTTL string = "ZTTL" ZPERSIST string = "ZPERSIST" ZKEYEXISTS string = "ZKEYEXISTS" ZRANGEBYLEX string = "ZRANGEBYLEX" LPUSH string = "LPUSH" RPUSH string = "RPUSH" LPOP string = "LPOP" RPOP string = "RPOP" LLEN string = "LLEN" LINDEX string = "LINDEX" LRANGE string = "LRANGE" LREM string = "LREM" LINSERT string = "LINSERT" LSET string = "LSET" LTRIM string = "LTRIM" LPUSHX string = "LPUSHX" RPUSHX string = "RPUSHX" LCLEAR string = "LCLEAR" LMCLEAR string = "LMCLEAR" LEXPIRE string = "LEXPIRE" LEXPIREAT string = "LEXPIREAT" LTTL string = "LTTL" LPERSIST string = "LPERSIST" LKEYEXISTS string = "LKEYEXISTS" LTRIMBACK string = "LTRIM_BACK" LTRIMFRONT string = "LTRIM_FRONT" WATCH string = "WATCH" UNWATCH string = "UNWATCH" MULTI string = "MULTI" EXEC string = "EXEC" PREPARE string = "PREPARE" DISCARD string = "DISCARD" EVAL string = "EVAL" SCRIPT string = "SCRIPT" EVALSHA string = "EVALSHA" GEOADD string = "GEOADD" GEODIST string = "GEODIST" GEOPOS string = "GEOPOS" GEOHASH string = "GEOHASH" GEORADIUS string = "GEORADIUS" GEORADIUSBYMEMBER string = "GEORADIUSBYMEMBER" )
View Source
const ( RangeClose uint8 = 0x00 RangeLopen uint8 = 0x01 RangeRopen uint8 = 0x10 )
View Source
const ( TagBeg = '{' TagEnd = '}' )
View Source
const ( TxStateNone int = 0 TxStateWatch int = 0x1 TxStateCancel int = 0x10 )
View Source
const ( DefaultCmdType uint8 = 0 MgetCmdType uint8 = 1 MsetCmdType uint8 = 2 DelCmdType uint8 = 3 )
View Source
const (
TxCommandNumLimit = 100
)
Variables ¶
View Source
var ( EmptyCommandErr = errors.New("empty command") NotFoundErr = errors.New("command not found") NotImplementErr = errors.New("command not implement") NotAuthenticatedErr = errors.New("not authenticated") AuthenticationFailureErr = errors.New("authentication failure") WriteErrorOnReadOnlyProxy = errors.New("Proxy Support READ COMMAND ONLY") RangeOffsetErr = errors.New("ERR offset is out of range") BitOffsetErr = errors.New("ERR bit offset is not an integer or out of range") SyntaxErr = errors.New("ERR syntax error") ValueErr = errors.New("ERR value is not an integer or out of range") FloatErr = errors.New("ERR value is not a valid float") HashTagErr = errors.New("ERR hashtag mismatch or missing") TxGroupChangedErr = errors.New("ERR group changed in tx") TxAbortErr = errors.New("EXECABORT Transaction discarded because of previous errors.") )
View Source
var ( Delims = []byte("\r\n") NullBulk = []byte("-1") NullArray = []byte("-1") ReplyOK = "OK" ReplyPONG = "PONG" ReplyQUEUED = "QUEUED" )
View Source
var NoScanMember = []byte("0")
Functions ¶
func CmdParamsErr ¶
func ExtractHashTag ¶
func InterfaceByte ¶
func InterfaceByte(items [][]byte) []interface{}
func InterfaceByteSubKeys ¶
func InterfaceString ¶
func InterfaceString(items []string) []interface{}
func LowerSlice ¶
func ParseSetArgs ¶
func ParseSetArgs(args [][]byte) (e ExpireType, t int64, c SetCondition, err error)
func Register ¶
func Register(name string, f CommandFunc)
func StringSlice ¶
func UpperSlice ¶
Types ¶
type CommandFunc ¶
type ExpireType ¶
type ExpireType string
const ( EX ExpireType = "EX" PX ExpireType = "PX" NoType ExpireType = "" )
type InternalServerConn ¶
type RespReader ¶
type RespReader struct {
// contains filtered or unexported fields
}
func NewRespReader ¶
func NewRespReader(conn net.Conn, size int) *RespReader
func (*RespReader) Parse ¶
func (resp *RespReader) Parse() (interface{}, error)
func (*RespReader) ParseBulkTo ¶
func (resp *RespReader) ParseBulkTo(w io.Writer) error
func (*RespReader) ParseRequest ¶
func (resp *RespReader) ParseRequest() ([][]byte, error)
type RespWriter ¶
type RespWriter struct {
// contains filtered or unexported fields
}
func NewRespWriter ¶
func NewRespWriter(conn net.Conn, size int) *RespWriter
func (*RespWriter) Flush ¶
func (w *RespWriter) Flush()
func (*RespWriter) WriteArray ¶
func (w *RespWriter) WriteArray(lst []interface{})
func (*RespWriter) WriteBulk ¶
func (w *RespWriter) WriteBulk(b []byte)
func (*RespWriter) WriteBulkFrom ¶
func (w *RespWriter) WriteBulkFrom(n int64, rb io.Reader)
func (*RespWriter) WriteError ¶
func (w *RespWriter) WriteError(err error)
func (*RespWriter) WriteFVPairArray ¶
func (w *RespWriter) WriteFVPairArray(lst [][]byte)
func (*RespWriter) WriteInteger ¶
func (w *RespWriter) WriteInteger(n int64)
func (*RespWriter) WriteScorePairArray ¶
func (w *RespWriter) WriteScorePairArray(lst [][]byte, withScores bool)
func (*RespWriter) WriteSliceArray ¶
func (w *RespWriter) WriteSliceArray(lst [][]byte)
func (*RespWriter) WriteStatus ¶
func (w *RespWriter) WriteStatus(status string)
type Session ¶
type Session struct { Cmd string Args [][]byte RespWriter *RespWriter RespReader *RespReader Stats *dostats.CalDoStats OpenDistributedTx bool TxState int TxCommandQueued bool Recorder *TxRecorder // contains filtered or unexported fields }
func NewSession ¶
func (*Session) GetTxClients ¶
func (s *Session) GetTxClients() map[int]*InternalServerConn
func (*Session) ReleaseTxClients ¶
func (s *Session) ReleaseTxClients()
func (*Session) SendTxQueued ¶
func (*Session) SetLastQueryTime ¶
func (s *Session) SetLastQueryTime()
func (*Session) SetQueryProperty ¶
func (*Session) SetReadDeadline ¶
func (s *Session) SetReadDeadline()
func (*Session) SetTxCancel ¶
func (*Session) SetTxClients ¶
func (s *Session) SetTxClients(clients map[int]*InternalServerConn)
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) AddSession ¶
func (m *SessionManager) AddSession(s *Session)
type SetCondition ¶
type SetCondition string
const ( NX SetCondition = "NX" XX SetCondition = "XX" NoCondition SetCondition = "" )
type TxCommandServerMap ¶
type TxRecorder ¶
type TxRecorder struct { CmdNum int MultiOk bool ServerClients map[int]*InternalServerConn ServerCmdNum map[int]int TxCommands []*TxCommandServerMap }
func (*TxRecorder) AddCommand ¶
func (tr *TxRecorder) AddCommand(gid int)
func (*TxRecorder) Reset ¶
func (tr *TxRecorder) Reset()
Click to show internal directories.
Click to hide internal directories.