engine

package
v0.0.0-...-c3f54fb Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(c common.Connection, redisArgs [][]byte) protocol.Reply

func BGRewriteAOF

func BGRewriteAOF(engine *Engine) protocol.Reply

异步方式重写aof

func DiscardMulti

func DiscardMulti(c common.Connection) protocol.Reply

取消事务

func EnqueueCmd

func EnqueueCmd(c common.Connection, redisCommand [][]byte) protocol.Reply

入队:保证命令在格式正确&& 存在的情况下入队

func ExecMulti

func ExecMulti(db *DB, conn common.Connection, args [][]byte) protocol.Reply

执行事务 exec rb

func GetRelatedKeys

func GetRelatedKeys(redisCommand [][]byte) ([]string, []string)

func Ping

func Ping(redisArgs [][]byte) protocol.Reply

常用:系统命令

func StartMulti

func StartMulti(c common.Connection) protocol.Reply

开启事务

func UnWatch

func UnWatch(db *DB, conn common.Connection) protocol.Reply

清空watch key

func Watch

func Watch(db *DB, conn common.Connection, args [][]byte) protocol.Reply

监视 key [key...]

Types

type CmdLine

type CmdLine = [][]byte

type DB

type DB struct {
	// contains filtered or unexported fields
}

func (*DB) Exec

func (db *DB) Exec(c common.Connection, redisCommand [][]byte) protocol.Reply

func (*DB) ExpireAt

func (db *DB) ExpireAt(key string, expireTime time.Time)

设定key过期

func (*DB) ExpireTime

func (db *DB) ExpireTime(key string) int64

绝对时间(过期) s

func (*DB) GetEntity

func (db *DB) GetEntity(key string) (*payload.DataEntity, bool)

************* Data Access ************** 获取内存中的数据

func (*DB) GetUndoLog

func (db *DB) GetUndoLog(cmdLine [][]byte) []CmdLine

获取命令的回滚命令

func (*DB) GetVersion

func (db *DB) GetVersion(key string) int64

************** Version **************

func (*DB) IsExpire

func (db *DB) IsExpire(key string) bool

判断key是否已过期

func (*DB) IsPersist

func (db *DB) IsPersist(key string) bool

判断是否key没有过期时间

func (*DB) PExpireTime

func (db *DB) PExpireTime(key string) int64

绝对时间(过期)ms

func (*DB) PTTL

func (db *DB) PTTL(key string) int64

相对时间(过期)ms

func (*DB) Persist

func (db *DB) Persist(key string)

设定key不过期

func (*DB) PutEntity

func (db *DB) PutEntity(key string, entity *payload.DataEntity) int

保存数据到内存中 (插入 or 更新)

func (*DB) PutIfAbsent

func (db *DB) PutIfAbsent(key string, entity *payload.DataEntity) int

保存数据到内存中 (插入 )

func (*DB) PutIfExist

func (db *DB) PutIfExist(key string, entity *payload.DataEntity) int

保存数据到内存中 (更新)

func (*DB) RWLock

func (db *DB) RWLock(readKeys, writeKeys []string)

func (*DB) RWUnLock

func (db *DB) RWUnLock(readKeys, writeKeys []string)

func (*DB) Remove

func (db *DB) Remove(key string)

删除key(单个)

func (*DB) Removes

func (db *DB) Removes(keys ...string) int64

删除多个key 返回成功删除个数

func (*DB) SetIndex

func (db *DB) SetIndex(index int)

func (*DB) TTL

func (db *DB) TTL(key string) int64

相对时间(过期)s

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

存储引擎,负责数据的CRUD

func NewEngine

func NewEngine() *Engine

func (*Engine) Close

func (e *Engine) Close()

func (*Engine) Exec

func (e *Engine) Exec(c common.Connection, redisCommand [][]byte) (result protocol.Reply)

redisCommand 待执行的命令 protocol.Reply 执行结果

func (*Engine) ExecWithLock

func (e *Engine) ExecWithLock(dbIndex int, redisCommand [][]byte) protocol.Reply

func (*Engine) ForEach

func (e *Engine) ForEach(dbIndex int, cb func(key string, data *payload.DataEntity, expiration *time.Time) bool)

遍历引擎的所有数据

func (*Engine) GetUndoLogs

func (e *Engine) GetUndoLogs(dbIndex int, redisCommand [][]byte) []CmdLine

func (*Engine) RWLocks

func (e *Engine) RWLocks(dbIndex int, readKeys, writeKeys []string)

func (*Engine) RWUnLocks

func (e *Engine) RWUnLocks(dbIndex int, readKeys, writeKeys []string)

type ExecFunc

type ExecFunc func(db *DB, args [][]byte) protocol.Reply

type KeysFunc

type KeysFunc func(args [][]byte) ([]string, []string) // read/write

type UndoFunc

type UndoFunc func(db *DB, args [][]byte) [][][]byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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