Documentation
¶
Overview ¶
Package command implements BoltCache's Redis-compatible command set. A single Engine executes commands for every transport (RESP, the legacy text protocol, REST and Lua scripts), so they all behave identically.
Index ¶
- func IsWrite(name string) bool
- func Names() []string
- func WriteMessage(w resp.Writer, channel, pattern, message string)
- type Authenticator
- type Config
- type Engine
- func (e *Engine) AuthRequired() bool
- func (e *Engine) Cache() *cache.BoltCache
- func (e *Engine) CheckPassword(p string) bool
- func (e *Engine) CloseSession(s *Session)
- func (e *Engine) Exec(s *Session, argv [][]byte, w resp.Writer)
- func (e *Engine) ExecStrings(s *Session, args []string, w resp.Writer)
- func (e *Engine) Hub() *pubsub.Hub
- func (e *Engine) Info(section string) string
- func (e *Engine) NewSession(addr string, sub pubsub.Subscriber) *Session
- func (e *Engine) Stats() (commands, rejected uint64)
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteMessage ¶
WriteMessage encodes a pub/sub message the way RESP2 subscribers expect.
Types ¶
type Authenticator ¶
Authenticator validates AUTH passwords (API tokens).
type Config ¶
type Config struct {
// Auth validates AUTH; nil (and no Passwords) disables authentication.
Auth Authenticator
// Passwords is a static alternative to Auth.
Passwords []string
// LuaEnabled enables EVAL/EVALSHA/SCRIPT.
LuaEnabled bool
// PubSubEnabled enables PUBLISH/SUBSCRIBE.
PubSubEnabled bool
// ScriptTimeout aborts scripts running longer than this (default 5s).
ScriptTimeout time.Duration
// Version is reported by INFO and HELLO.
Version string
}
Config controls optional engine features.
type Engine ¶
type Engine struct {
// Optional hooks used by INFO/SAVE; set before serving.
Persister *cache.Persister
ClientCount func() int64
// contains filtered or unexported fields
}
Engine executes commands against a cache.
func (*Engine) AuthRequired ¶
AuthRequired reports whether clients must authenticate.
func (*Engine) CheckPassword ¶
CheckPassword validates p in constant time.
func (*Engine) CloseSession ¶
CloseSession releases resources held by s (subscriptions).
func (*Engine) ExecStrings ¶
ExecStrings is Exec for already converted arguments.
func (*Engine) Info ¶
Info renders the INFO text for the given section ("" or "all" for every section).
func (*Engine) NewSession ¶
func (e *Engine) NewSession(addr string, sub pubsub.Subscriber) *Session
NewSession creates a session; it's pre-authenticated when no password is configured.
type Session ¶
type Session struct {
ID int64
Name string
Addr string
Authenticated bool
// Subscriber receives pub/sub messages; nil when the transport doesn't
// support subscriptions.
Subscriber pubsub.Subscriber
// Close is set when the client asked to close the connection (QUIT).
Close bool
// contains filtered or unexported fields
}
Session holds per-connection state.
func (*Session) Subscriptions ¶
Subscriptions returns the number of channel and pattern subscriptions.