Documentation
¶
Overview ¶
Package database is a memory database with redis compatible interface
Index ¶
- func Auth(c redis.Connection, args [][]byte) redis.Reply
- func BGRewriteAOF(db *Server, args [][]byte) redis.Reply
- func BGSaveRDB(db *Server, args [][]byte) redis.Reply
- func DbSize(c redis.Connection, db *Server) redis.Reply
- func DiscardMulti(conn redis.Connection) redis.Reply
- func EnqueueCmd(conn redis.Connection, cmdLine [][]byte) redis.Reply
- func GenGodisInfoString(section string, db *Server) []byte
- func GetRelatedKeys(cmdLine [][]byte) ([]string, []string)
- func Info(db *Server, args [][]byte) redis.Reply
- func NewPersister(db database.DBEngine, filename string, load bool, fsync string) (*aof.Persister, error)
- func Ping(c redis.Connection, args [][]byte) redis.Reply
- func RewriteAOF(db *Server, args [][]byte) redis.Reply
- func SaveRDB(db *Server, args [][]byte) redis.Reply
- func StartMulti(conn redis.Connection) redis.Reply
- func Watch(db *DB, conn redis.Connection, args [][]byte) redis.Reply
- type CmdLine
- type DB
- func (db *DB) Exec(c redis.Connection, cmdLine [][]byte) redis.Reply
- func (db *DB) ExecMulti(conn redis.Connection, watching map[string]uint32, cmdLines []CmdLine) redis.Reply
- func (db *DB) Expire(key string, expireTime time.Time)
- func (db *DB) Flush()
- func (db *DB) ForEach(cb func(key string, data *database.DataEntity, expiration *time.Time) bool)
- func (db *DB) GetEntity(key string) (*database.DataEntity, bool)
- func (db *DB) GetUndoLogs(cmdLine [][]byte) []CmdLine
- func (db *DB) GetVersion(key string) uint32
- func (db *DB) IsExpired(key string) bool
- func (db *DB) Persist(key string)
- func (db *DB) PutEntity(key string, entity *database.DataEntity) int
- func (db *DB) PutIfAbsent(key string, entity *database.DataEntity) int
- func (db *DB) PutIfExists(key string, entity *database.DataEntity) int
- func (db *DB) RWLocks(writeKeys []string, readKeys []string)
- func (db *DB) RWUnLocks(writeKeys []string, readKeys []string)
- func (db *DB) Remove(key string)
- func (db *DB) Removes(keys ...string) (deleted int)
- type ExecFunc
- type PreFunc
- type Server
- func (server *Server) AddAof(dbIndex int, cmdLine CmdLine)
- func (server *Server) AfterClientClose(c redis.Connection)
- func (server *Server) Close()
- func (server *Server) Exec(c redis.Connection, cmdLine [][]byte) (result redis.Reply)
- func (server *Server) ExecMulti(conn redis.Connection, watching map[string]uint32, cmdLines []CmdLine) redis.Reply
- func (server *Server) ExecWithLock(conn redis.Connection, cmdLine [][]byte) redis.Reply
- func (server *Server) ForEach(dbIndex int, ...)
- func (server *Server) GetAvgTTL(dbIndex, randomKeyCount int) int64
- func (server *Server) GetDBSize(dbIndex int) (int, int)
- func (server *Server) GetEntity(dbIndex int, key string) (*database.DataEntity, bool)
- func (server *Server) GetExpiration(dbIndex int, key string) *time.Time
- func (server *Server) GetUndoLogs(dbIndex int, cmdLine [][]byte) []CmdLine
- func (server *Server) LoadRDB(dec *core.Decoder) error
- func (server *Server) RWLocks(dbIndex int, writeKeys []string, readKeys []string)
- func (server *Server) RWUnLocks(dbIndex int, writeKeys []string, readKeys []string)
- func (server *Server) SetKeyDeletedCallback(cb database.KeyEventCallback)
- func (server *Server) SetKeyInsertedCallback(cb database.KeyEventCallback)
- type UndoFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth(c redis.Connection, args [][]byte) redis.Reply
Auth validate client's password
func BGRewriteAOF ¶
BGRewriteAOF asynchronously rewrites Append-Only-File
func DiscardMulti ¶
func DiscardMulti(conn redis.Connection) redis.Reply
DiscardMulti drops MULTI pending commands
func EnqueueCmd ¶
func EnqueueCmd(conn redis.Connection, cmdLine [][]byte) redis.Reply
EnqueueCmd puts command line into `multi` pending queue
func GenGodisInfoString ¶
func GetRelatedKeys ¶
GetRelatedKeys analysis related keys
func NewPersister ¶
func RewriteAOF ¶
RewriteAOF start Append-Only-File rewriting and blocked until it finished
func StartMulti ¶
func StartMulti(conn redis.Connection) redis.Reply
StartMulti starts multi-command-transaction
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB stores data and execute user's commands
func (*DB) ExecMulti ¶
func (db *DB) ExecMulti(conn redis.Connection, watching map[string]uint32, cmdLines []CmdLine) redis.Reply
ExecMulti executes multi commands transaction Atomically and Isolated
func (*DB) GetEntity ¶
func (db *DB) GetEntity(key string) (*database.DataEntity, bool)
GetEntity returns DataEntity bind to given key
func (*DB) GetUndoLogs ¶
GetUndoLogs return rollback commands
func (*DB) GetVersion ¶
GetVersion returns version code for given key
func (*DB) PutEntity ¶
func (db *DB) PutEntity(key string, entity *database.DataEntity) int
PutEntity a DataEntity into DB
func (*DB) PutIfAbsent ¶
func (db *DB) PutIfAbsent(key string, entity *database.DataEntity) int
PutIfAbsent insert an DataEntity only if the key not exists
func (*DB) PutIfExists ¶
func (db *DB) PutIfExists(key string, entity *database.DataEntity) int
PutIfExists edit an existing DataEntity
type PreFunc ¶
PreFunc analyses command line when queued command to `multi` returns related write keys and read keys
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a redis-server with full capabilities including multiple database, rdb loader, replication
func MakeAuxiliaryServer ¶
func MakeAuxiliaryServer() *Server
MakeAuxiliaryServer create a Server only with basic capabilities for aof rewrite and other usages
func NewStandaloneServer ¶
func NewStandaloneServer() *Server
NewStandaloneServer creates a standalone redis server, with multi database and all other funtions
func (*Server) AfterClientClose ¶
func (server *Server) AfterClientClose(c redis.Connection)
AfterClientClose does some clean after client close connection
func (*Server) Exec ¶
Exec executes command parameter `cmdLine` contains command and its arguments, for example: "set key value"
func (*Server) ExecMulti ¶
func (server *Server) ExecMulti(conn redis.Connection, watching map[string]uint32, cmdLines []CmdLine) redis.Reply
ExecMulti executes multi commands transaction Atomically and Isolated
func (*Server) ExecWithLock ¶
ExecWithLock executes normal commands, invoker should provide locks
func (*Server) ForEach ¶
func (server *Server) ForEach(dbIndex int, cb func(key string, data *database.DataEntity, expiration *time.Time) bool)
ForEach traverses all the keys in the given database
func (*Server) GetExpiration ¶
func (*Server) GetUndoLogs ¶
GetUndoLogs return rollback commands
func (*Server) SetKeyDeletedCallback ¶
func (server *Server) SetKeyDeletedCallback(cb database.KeyEventCallback)
func (*Server) SetKeyInsertedCallback ¶
func (server *Server) SetKeyInsertedCallback(cb database.KeyEventCallback)