Documentation ¶
Index ¶
- Variables
- func ParseReply(rd *bufio.Reader) (interface{}, error)
- type Cmd
- type DisconnectHandler
- type Hook
- type Peer
- func (c *Peer) Block(f func(*Writer))
- func (c *Peer) Close()
- func (c *Peer) Closed() bool
- func (c *Peer) Flush()
- func (c *Peer) OnDisconnect(f func())
- func (c *Peer) WriteBulk(s string)
- func (c *Peer) WriteError(e string)
- func (c *Peer) WriteFloat(n float64)
- func (c *Peer) WriteInline(s string)
- func (c *Peer) WriteInt(n int)
- func (c *Peer) WriteLen(n int)
- func (c *Peer) WriteMapLen(n int)
- func (c *Peer) WriteNull()
- func (c *Peer) WriteOK()
- func (c *Peer) WritePushLen(n int)
- func (c *Peer) WriteRaw(s string)
- func (c *Peer) WriteSetLen(n int)
- func (c *Peer) WriteStrings(strs []string)
- type Server
- func (s *Server) Addr() *net.TCPAddr
- func (s *Server) ClientsLen() int
- func (s *Server) Close()
- func (s *Server) Dispatch(c *Peer, args []string)
- func (s *Server) Register(cmd string, f Cmd) error
- func (s *Server) ServeConn(conn net.Conn)
- func (s *Server) SetPreHook(h Hook)
- func (s *Server) TotalCommands() int
- func (s *Server) TotalConnections() int
- type Simple
- type Writer
- func (w *Writer) Flush()
- func (w *Writer) WriteBulk(s string)
- func (w *Writer) WriteError(e string)
- func (w *Writer) WriteFloat(n float64)
- func (w *Writer) WriteInline(s string)
- func (w *Writer) WriteInt(n int)
- func (w *Writer) WriteLen(n int)
- func (w *Writer) WriteMapLen(n int)
- func (w *Writer) WriteNull()
- func (w *Writer) WritePushLen(n int)
- func (w *Writer) WriteRaw(s string)
- func (w *Writer) WriteSetLen(n int)
- func (w *Writer) WriteStrings(strs []string)
Constants ¶
This section is empty.
Variables ¶
var ErrProtocol = errors.New("invalid request")
ErrProtocol is the general error for unexpected input
Functions ¶
func ParseReply ¶ added in v2.11.2
parse a reply
Types ¶
type DisconnectHandler ¶
type DisconnectHandler func(c *Peer)
type Hook ¶ added in v2.13.0
Hook is can be added to run before every cmd. Return true if the command is done.
type Peer ¶
type Peer struct { Resp3 bool Ctx interface{} // anything goes, server won't touch this // contains filtered or unexported fields }
Peer is a client connected to the server
func (*Peer) Close ¶
func (c *Peer) Close()
Close the client connection after the current command is done.
func (*Peer) Flush ¶
func (c *Peer) Flush()
Flush the write buffer. Called automatically after every redis command
func (*Peer) OnDisconnect ¶
func (c *Peer) OnDisconnect(f func())
Register a function to execute on disconnect. There can be multiple functions registered.
func (*Peer) WriteFloat ¶ added in v2.14.0
WriteFloat writes a float
func (*Peer) WriteInline ¶
WriteInline writes a redis inline string
func (*Peer) WriteMapLen ¶ added in v2.14.0
WriteMapLen starts a map with the given length (number of keys)
func (*Peer) WritePushLen ¶ added in v2.14.0
WritePushLen starts a push-data array with the given length
func (*Peer) WriteSetLen ¶ added in v2.14.0
WriteSetLen starts a set with the given length (number of elements)
func (*Peer) WriteStrings ¶ added in v2.15.0
WriteStrings is a helper to (bulk)write a string list
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a simple redis server
func NewServerTLS ¶ added in v2.13.0
func (*Server) ClientsLen ¶
ClientsLen gives the number of connected clients right now
func (*Server) Close ¶
func (s *Server) Close()
Close a server started with NewServer. It will wait until all clients are closed.
func (*Server) Register ¶
Register a command. It can't have been registered before. Safe to call on a running server.
func (*Server) SetPreHook ¶ added in v2.13.0
(un)set a hook which is ran before every call. It returns true if the command is done.
func (*Server) TotalCommands ¶
TotalCommands is total (known) commands since this the server started
func (*Server) TotalConnections ¶
TotalConnections give the number of clients connected since the server started, including the currently connected ones
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer is given to the callback in Block()
func (*Writer) WriteFloat ¶ added in v2.14.0
WriteFloat writes a float
func (*Writer) WriteInline ¶
WriteInline writes a redis inline string
func (*Writer) WriteMapLen ¶ added in v2.14.0
func (*Writer) WritePushLen ¶ added in v2.14.0
func (*Writer) WriteSetLen ¶ added in v2.14.0
func (*Writer) WriteStrings ¶ added in v2.15.0
WriteStrings writes a list of strings (bulk)