pkg

package
v0.0.0-...-2aef611 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjEncodingRaw        = iota // raw
	ObjEncodingInt        = iota // int
	ObjEncodingHt         = iota //hash
	ObjEncodingZipMap     = iota // zipmap
	ObjEncodingLinkedList = iota // No longer used: old list encoding
	ObjEncodingZipList    = iota // ziplist
	ObjEncodingIntSet     = iota // intset
	ObjEncodingSkipList   = iota // skiplist
	ObjEncodingEmbStr     = iota // Embedded sds string encoding
	ObjEncodingQuickList  = iota // linked list of ziplists
	ObjEncodingStream     = iota // radix tree of listpacks
)
View Source
const (
	ObjString = iota
	ObjList   = iota
	ObjSet    = iota
	ObjZSet   = iota
	ObjHash   = iota
	ObjModule = iota
	ObjStream = iota
)
View Source
const (
	AofOff = 0
	AofOn  = 1
)
View Source
const CErr = 0
View Source
const COk = 1
View Source
const CRLF = "\r\n"
View Source
const ClientSlave = 1 << 0
View Source
const LongStrSize = 21 /* Bytes needed for long -> str + '\0' */
View Source
const LookupNone = 0
View Source
const ObjSharedBulkhdrLen = 32
View Source
const ObjSharedIntegers = 10000
View Source
const ObjSharedRefcount = 2147483647
View Source
const ProtoInlineMaxSize = 1024 * 64 /* Max size of inline reads */
View Source
const ProtoIoBufLen = 1024 /* Generic I/O buffer size */
View Source
const ProtoMBulkBigArg = 1024 * 32
View Source
const ProtoMaxQueryBufLen = 1024 * 1024 * 1024 /* 1GB max query buffer. */
View Source
const ProtoReplyChunkBytes = 16 * 1024 /* 16k output buffer */

const ProtoIoBufLen = 1024 * 16 /* Generic I/O buffer size */

View Source
const REPL_STATE_CONNECT = 1
View Source
const REPL_STATE_CONNECTED = 15
View Source
const REPL_STATE_CONNECTING = 2
View Source
const REPL_STATE_NONE = 0
View Source
const REPL_STATE_TRANSFER = 14
View Source
const RedisAutoSyncBytes = 1024 * 1024 * 32 /* fdatasync every 32MB */
View Source
const RedisVersion = "5.0.5"
View Source
const SharedSelectCmds = 10

Variables

View Source
var CommandGroups = [...]string{
	"generic",
	"string",
	"list",
	"set",
	"sorted_set",
	"hash",
	"pubsub",
	"transactions",
	"connection",
	"server",
	"scripting",
	"hyperloglog",
	"cluster",
	"geo",
	"stream",
}

Functions

func CatAppendOnlyGenericCommand

func CatAppendOnlyGenericCommand(buf string, argv []*RedisObject) string

func ConnectWithMaster

func ConnectWithMaster() int

func Cron

func Cron()

func GetCommandMessage

func GetCommandMessage(ss []*RedisObject) []string

func IsSdsRepresentableAsLongLong

func IsSdsRepresentableAsLongLong(s string) int

func ParseProtocol

func ParseProtocol()

func ProtocolArr

func ProtocolArr(messages []string) string

数组,数组的情况比较复杂,实现时再说 @todo

func ProtocolArrNull

func ProtocolArrNull() string

数组nil

func ProtocolInt

func ProtocolInt(message int) string

整型数字,有符号64位整型

func ProtocolLine

func ProtocolLine(message string) string

单行回复,简单字符串,非二进制安全

func ProtocolLineErr

func ProtocolLineErr(message string) string

错误信息

func ProtocolMultiLine

func ProtocolMultiLine(messages []string) string

多行字符串,多行字符串用于表示长度最大为512 MB的单个二进制安全字符串。

func ProtocolNull

func ProtocolNull() string

多行字符串,返回nil

func ReplicationCron

func ReplicationCron()

func S2Int

func S2Int(s string) int

func ServerCron

func ServerCron()

func StartLoading

func StartLoading(file *os.File)

func SyncWithMaster

func SyncWithMaster()

func Test

func Test()

Types

type Aof

type Aof struct {
	Fd  *os.File
	Log log.ILog
}

* *** 写入aof文件 *

func NewAof

func NewAof() *Aof

func (*Aof) Close

func (a *Aof) Close()

关闭

func (*Aof) Create

func (a *Aof) Create()

创建aof文件

func (*Aof) Load

func (a *Aof) Load(cl *Client)

func (*Aof) LoadAppendOnlyFile

func (a *Aof) LoadAppendOnlyFile(filename string) int

加载aof文件

func (*Aof) LoadFile

func (a *Aof) LoadFile(f *os.File, cl *Client) (int, bool)

func (*Aof) ParseMultiBulkLen

func (a *Aof) ParseMultiBulkLen(cl *Client) bool

func (*Aof) ParseStart

func (a *Aof) ParseStart(cl *Client) bool

func (*Aof) Write

func (a *Aof) Write(content string)

写入

type Client

type Client struct {
	Conn            net.Conn
	Index           int
	Name            string
	Log             log.ILog
	Db              *RedisDb
	QueryBuf        []byte
	Query           string
	Argv            []*RedisObject
	LastInteraction string
	ReqType         int // 协议类型
	MultiBulkLen    int
	QbPos           int
	BulkLen         int
	Cmd             *RedisCommand
	LastCmd         *RedisCommand
	Pending         chan *Pending
	Flags           int
	PubSubChannel   map[string]bool
}

func CreateFakeClient

func CreateFakeClient() *Client

func NewClient

func NewClient(conn net.Conn) *Client

func (*Client) AddReply

func (cl *Client) AddReply(message string)

func (*Client) AddReplyBulk

func (cl *Client) AddReplyBulk(object *RedisObject)

func (*Client) AddReplyBulkLen

func (cl *Client) AddReplyBulkLen(object *RedisObject)

func (*Client) AddReplyError

func (cl *Client) AddReplyError(message string)

func (*Client) AddReplyErrorFormat

func (cl *Client) AddReplyErrorFormat(args []string, messages ...string)

func (*Client) AddReplyHelp

func (cl *Client) AddReplyHelp(help []string)

func (*Client) AddReplyLongLong

func (cl *Client) AddReplyLongLong(s int)

func (*Client) AddReplyRedisObject

func (cl *Client) AddReplyRedisObject(object *RedisObject)

func (*Client) AddReplySubcommandSyntaxError

func (cl *Client) AddReplySubcommandSyntaxError()

func (*Client) Free

func (cl *Client) Free()

func (*Client) FreeFakeClient

func (cl *Client) FreeFakeClient()

func (*Client) GetArgvByIndex

func (cl *Client) GetArgvByIndex(i int) string

func (*Client) LookupKeyReadOrReply

func (cl *Client) LookupKeyReadOrReply(key *RedisObject, reply *RedisObject) *RedisObject

func (*Client) ParseCommand

func (cl *Client) ParseCommand() bool

func (*Client) SelectDb

func (cl *Client) SelectDb(id int) int

type ClusterNode

type ClusterNode struct {
}

type ClusterState

type ClusterState struct {
}

type Dict

type Dict struct {
	Storage map[string]*RedisObject
}

func NewDict

func NewDict() *Dict

func (*Dict) Add

func (d *Dict) Add(key *RedisObject, value *RedisObject)

func (*Dict) Get

func (d *Dict) Get(key *RedisObject) *RedisObject

type Pending

type Pending struct {
}

type PubSubPattern

type PubSubPattern struct {
	Client  *Client
	Pattern *RedisObject
}

type Rdb

type Rdb struct {
}

rio.h

type RedisCommand

type RedisCommand struct {
	Name         string
	Proc         func(c *Client)
	Arity        int
	SFlags       string
	Flags        int
	GetKeysProc  *int
	FirstKey     int
	LastKey      int
	KeyStep      int
	Microseconds int
	Calls        int
}

func LookupCommand

func LookupCommand(cmd string) (*RedisCommand, bool)

func (*RedisCommand) FeedAppendOnlyFile

func (rc *RedisCommand) FeedAppendOnlyFile(dbid int, argv []*RedisObject)

func (*RedisCommand) Propagate

func (rc *RedisCommand) Propagate(dbid int, argv []*RedisObject, flags int)

type RedisDb

type RedisDb struct {
	Id     int
	AvgTtl int
	Dict   *Dict
}

func NewRedisDb

func NewRedisDb(id int) *RedisDb

func (*RedisDb) Add

func (rb *RedisDb) Add(key *RedisObject, value *RedisObject)

func (*RedisDb) LookupKey

func (rb *RedisDb) LookupKey(key *RedisObject, flags int) *RedisObject

func (*RedisDb) LookupKeyRead

func (rb *RedisDb) LookupKeyRead(key *RedisObject) *RedisObject

func (*RedisDb) LookupKeyReadWithFlags

func (rb *RedisDb) LookupKeyReadWithFlags(key *RedisObject, flags int) *RedisObject

func (RedisDb) LookupKeyWrite

func (rb RedisDb) LookupKeyWrite(key *RedisObject) *RedisObject

type RedisObject

type RedisObject struct {
	Encoding int
	TypeFlag int
	Lru      int
	Refcount int
	Ptr      interface{}
}

func CreateHashRedisObject

func CreateHashRedisObject() *RedisObject

func CreateIntSetObject

func CreateIntSetObject() *RedisObject

func CreateQuickListObject

func CreateQuickListObject() *RedisObject

func CreateSetObject

func CreateSetObject() *RedisObject

func NewRedisObject

func NewRedisObject(typeFlag int, ptr interface{}) *RedisObject

func NewStringRedisObject

func NewStringRedisObject(s string) *RedisObject

func SetTypeCreate

func SetTypeCreate(s string) *RedisObject

func (*RedisObject) DecrRefCount

func (r *RedisObject) DecrRefCount()

func (*RedisObject) MakeShared

func (r *RedisObject) MakeShared() *RedisObject

type ReplicationMain

type ReplicationMain struct {
	Host   string
	Port   int
	Client *Client
	Auth   string
	State  int
}

Main server info

func NewReplicationMain

func NewReplicationMain(conn net.Conn) *ReplicationMain

func (*ReplicationMain) ReplicationUnsetMaster

func (m *ReplicationMain) ReplicationUnsetMaster()

type ReplicationReplica

type ReplicationReplica struct {
	Host  string
	Port  int
	State int
}

type Server

type Server struct {
	RequirePass          bool
	Log                  log.ILog
	Clients              map[int]*Client
	Db                   []*RedisDb
	No                   int
	StatRejectedConn     int
	CurrentClient        chan *Client
	Listener             net.Listener
	Aof                  *Aof
	WaitCloseClients     chan int
	NewClients           chan net.Conn
	Commands             map[string]*RedisCommand
	ClientMaxQueryBufLen int
	AofState             int
	AofFsync             int
	AofSelectedDb        int
	ReplicaList          []*ReplicationReplica
	Main                 *ReplicationMain
	PubSubChannels       map[string][]*Client
	Monitors             []*Client
}

func NewServer

func NewServer() *Server

func (*Server) LoadDataFromDisk

func (s *Server) LoadDataFromDisk()

Jump to

Keyboard shortcuts

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