github.com/hdt3213/godis@v1.2.9/interface/database/db.go (about) 1 package database 2 3 import ( 4 "time" 5 6 "github.com/hdt3213/godis/interface/redis" 7 "github.com/hdt3213/rdb/core" 8 ) 9 10 // CmdLine is alias for [][]byte, represents a command line 11 type CmdLine = [][]byte 12 13 // DB is the interface for redis style storage engine 14 type DB interface { 15 Exec(client redis.Connection, cmdLine [][]byte) redis.Reply 16 AfterClientClose(c redis.Connection) 17 Close() 18 LoadRDB(dec *core.Decoder) error 19 } 20 21 // DBEngine is the embedding storage engine exposing more methods for complex application 22 type DBEngine interface { 23 DB 24 ExecWithLock(conn redis.Connection, cmdLine [][]byte) redis.Reply 25 ExecMulti(conn redis.Connection, watching map[string]uint32, cmdLines []CmdLine) redis.Reply 26 GetUndoLogs(dbIndex int, cmdLine [][]byte) []CmdLine 27 ForEach(dbIndex int, cb func(key string, data *DataEntity, expiration *time.Time) bool) 28 RWLocks(dbIndex int, writeKeys []string, readKeys []string) 29 RWUnLocks(dbIndex int, writeKeys []string, readKeys []string) 30 GetDBSize(dbIndex int) (int, int) 31 } 32 33 // DataEntity stores data bound to a key, including a string, list, hash, set and so on 34 type DataEntity struct { 35 Data interface{} 36 }