Documentation ¶
Index ¶
- Constants
- Variables
- func CreateValueDump(rtype byte, data []byte) []byte
- func Float64ToByte(float float64) string
- func ParseRdb(reader io.Reader, rbytes *atomic.Int64, size int, options ...RdbParseOption) chan *BinEntry
- func ParseRdbVersion(reader *os.File) (string, error)
- type AuxParser
- type BaseParser
- func (bp *BaseParser) CanRestore() bool
- func (bp *BaseParser) CreateValueDump() []byte
- func (bp *BaseParser) DB() uint32
- func (bp *BaseParser) FirstBin() bool
- func (bp *BaseParser) IsSplited() bool
- func (bp *BaseParser) Key() []byte
- func (bp *BaseParser) RdbType() int
- func (bp *BaseParser) Type() int
- func (bp *BaseParser) Value() []byte
- func (bp *BaseParser) ValueDumpSize() int
- type BinEntry
- type CountReader
- type FunctionParser
- type HashPaser
- type ListParser
- type Loader
- type ModuleParser
- type Parser
- type RdbObjExecutor
- type RdbParseOption
- type RdbReader
- func (r *RdbReader) CountZipmapItems(buf *util.SliceBuffer) int
- func (r *RdbReader) CountZipmapItemsP(buf *util.SliceBuffer) int
- func (r *RdbReader) Read(p []byte) (int, error)
- func (r *RdbReader) Read16ByteP() []byte
- func (r *RdbReader) Read8ByteP() []byte
- func (r *RdbReader) ReadByte() (byte, error)
- func (r *RdbReader) ReadByteP() byte
- func (r *RdbReader) ReadBytes(n int) ([]byte, error)
- func (r *RdbReader) ReadBytesP(n int) []byte
- func (r *RdbReader) ReadDouble() (float64, error)
- func (r *RdbReader) ReadDoubleP() float64
- func (r *RdbReader) ReadFloat() (float64, error)
- func (r *RdbReader) ReadFloatP() float64
- func (r *RdbReader) ReadInt16() (int16, error)
- func (r *RdbReader) ReadInt32() (int32, error)
- func (r *RdbReader) ReadInt8() (int8, error)
- func (r *RdbReader) ReadLength() (uint32, error)
- func (r *RdbReader) ReadLength64() (uint64, error)
- func (r *RdbReader) ReadLength64P() uint64
- func (r *RdbReader) ReadLengthP() uint32
- func (r *RdbReader) ReadString() ([]byte, error)
- func (r *RdbReader) ReadStringP() []byte
- func (r *RdbReader) ReadUint16() (uint16, error)
- func (r *RdbReader) ReadUint32() (uint32, error)
- func (r *RdbReader) ReadUint32BigEndian() (uint32, error)
- func (r *RdbReader) ReadUint32P() uint32
- func (r *RdbReader) ReadUint64() (uint64, error)
- func (r *RdbReader) ReadUint64BigEndian() (uint64, error)
- func (r *RdbReader) ReadUint64P() uint64
- func (r *RdbReader) ReadUint8() (uint8, error)
- func (r *RdbReader) ReadUint8P() uint8
- func (r *RdbReader) ReadZipmapItem(buf *util.SliceBuffer, readFree bool) []byte
- func (r *RdbReader) ReadZipmapItemP(buf *util.SliceBuffer, readFree bool) []byte
- type SetParser
- type StreamParser
- type StringParser
- type ZSetParser
Constants ¶
const ( RdbObjectString = iota RdbObjectList = iota RdbObjectSet = iota RdbObjectZSet = iota RdbObjectHash = iota RdbObjectStream = iota RdbObjectModule = iota RdbObjectFunction = iota RdbObjectAux = iota )
const ( RdbTypeString = 0 RdbTypeList = 1 RdbTypeSet = 2 RdbTypeZSet = 3 RdbTypeHash = 4 RdbTypeZSet2 = 5 RdbTypeModule = 6 RdbTypeModule2 = 7 RdbTypeHashZipmap = 9 RdbTypeListZiplist = 10 RdbTypeSetIntset = 11 RdbTypeZSetZiplist = 12 RdbTypeHashZiplist = 13 RdbTypeQuicklist = 14 RDBTypeStreamListPacks = 15 // stream RdbTypeHashListpack = 16 RdbTypeZSetListpack = 17 RdbTypeQuicklist2 = 18 RDBTypeStreamListPacks2 = 19 // stream RdbTypeSetListpack = 20 RdbTypeStreamListPacks3 = 21 // RDB_TYPE_STREAM_LISTPACKS_3 RdbTypeFunction2 = 0xf5 RdbTypeFunction = 0xf6 RdbFlagModuleAux = 0xf7 RdbFlagIdle = 0xf8 RdbFlagFreq = 0xf9 RdbFlagAUX = 0xfa RdbFlagResizeDB = 0xfb RdbFlagExpiryMS = 0xfc RdbFlagExpiry = 0xfd RdbFlagSelectDB = 0xfe RdbFlagEOF = 0xff )
const ( RdbRedisSignature = "REDIS" RdbAuxFieldMarker = 0xFA RdbRedisVersionKey = "redis-ver" )
Variables ¶
var RdbVersion int64 = 11 // redis:7.2.0
var RdbVersion int64 = 10 // redis:7.0.0
Functions ¶
func CreateValueDump ¶
func Float64ToByte ¶
Types ¶
type AuxParser ¶
type AuxParser struct {
BaseParser
}
aux redis, rdb.c:rdbSaveInfoAuxFields,rdbSaveModulesAux
func (*AuxParser) ExecCmd ¶
func (fp *AuxParser) ExecCmd(cb RdbObjExecutor)
func (*AuxParser) ReadBuffer ¶
type BaseParser ¶
type BaseParser struct {
// contains filtered or unexported fields
}
func (*BaseParser) CanRestore ¶
func (bp *BaseParser) CanRestore() bool
func (*BaseParser) CreateValueDump ¶
func (bp *BaseParser) CreateValueDump() []byte
redis, cluster.c:verifyDumpPayload
func (*BaseParser) DB ¶
func (bp *BaseParser) DB() uint32
func (*BaseParser) FirstBin ¶
func (bp *BaseParser) FirstBin() bool
func (*BaseParser) IsSplited ¶
func (bp *BaseParser) IsSplited() bool
func (*BaseParser) Key ¶
func (bp *BaseParser) Key() []byte
func (*BaseParser) RdbType ¶
func (bp *BaseParser) RdbType() int
func (*BaseParser) Type ¶
func (bp *BaseParser) Type() int
func (*BaseParser) Value ¶
func (bp *BaseParser) Value() []byte
func (*BaseParser) ValueDumpSize ¶
func (bp *BaseParser) ValueDumpSize() int
type BinEntry ¶
type BinEntry struct { DB int Key []byte Type byte ExpireAt uint64 IdleTime uint32 Freq uint8 Err error ObjectParser Parser Done bool // contains filtered or unexported fields }
func (*BinEntry) CanRestore ¶
type CountReader ¶ added in v1.0.0
type CountReader struct {
// contains filtered or unexported fields
}
func NewCountReader ¶ added in v1.0.0
func NewCountReader(r io.Reader, p *atomic.Int64) *CountReader
func (*CountReader) Count ¶ added in v1.0.0
func (r *CountReader) Count() int64
func (*CountReader) ResetCounter ¶ added in v1.0.0
func (r *CountReader) ResetCounter() int64
type FunctionParser ¶
type FunctionParser struct { BaseParser // contains filtered or unexported fields }
function
func (*FunctionParser) ExecCmd ¶
func (fp *FunctionParser) ExecCmd(cb RdbObjExecutor)
func (*FunctionParser) ReadBuffer ¶
func (fp *FunctionParser) ReadBuffer(lr *Loader)
type HashPaser ¶
type HashPaser struct {
BaseParser
}
func (*HashPaser) ExecCmd ¶
func (hp *HashPaser) ExecCmd(cb RdbObjExecutor)
func (*HashPaser) ReadBuffer ¶
RdbTypeHash RdbTypeHashZipmap RdbTypeHashZiplist RdbTypeHashListpack redis7.2(rdb 11) : if (sdslen(field)>64 || sdslen(value) > 64), RdbTypeHash; else RdbTypeHashListpack redis4.0(rdb 8) : if (ziplistLen(ziplist) < 512) then RdbTypeHashZiplist; else RdbTypeHash,
type ListParser ¶
type ListParser struct {
BaseParser
}
list
func (*ListParser) ExecCmd ¶
func (lp *ListParser) ExecCmd(cb RdbObjExecutor)
type ModuleParser ¶
type ModuleParser struct { BaseParser // contains filtered or unexported fields }
module
func (*ModuleParser) ExecCmd ¶
func (mp *ModuleParser) ExecCmd(cb RdbObjExecutor)
func (*ModuleParser) ReadBuffer ¶
func (mp *ModuleParser) ReadBuffer(lr *Loader)
type Parser ¶
type Parser interface { Type() int RdbType() int ReadBuffer(*Loader) ExecCmd(RdbObjExecutor) Key() []byte Value() []byte CreateValueDump() []byte ValueDumpSize() int FirstBin() bool IsSplited() bool DB() uint32 CanRestore() bool }
Parser parse rdb to redis commands throw panic if something is wrong redis : rdb.c:rdbLoadObject, rdbSaveRio
type RdbObjExecutor ¶
type RdbParseOption ¶ added in v1.0.0
type RdbParseOption func(o *rdbParseOptions)
func WithFunctionExists ¶ added in v1.0.0
func WithFunctionExists(functionExists string) RdbParseOption
func WithTargetRedisVersion ¶ added in v1.0.0
func WithTargetRedisVersion(version string) RdbParseOption
type RdbReader ¶
type RdbReader struct {
// contains filtered or unexported fields
}
func NewRdbReader ¶
func (*RdbReader) CountZipmapItems ¶
func (r *RdbReader) CountZipmapItems(buf *util.SliceBuffer) int
func (*RdbReader) CountZipmapItemsP ¶
func (r *RdbReader) CountZipmapItemsP(buf *util.SliceBuffer) int
func (*RdbReader) Read16ByteP ¶
func (*RdbReader) Read8ByteP ¶
func (*RdbReader) ReadBytesP ¶
func (*RdbReader) ReadDouble ¶
func (*RdbReader) ReadDoubleP ¶
func (*RdbReader) ReadFloatP ¶
func (*RdbReader) ReadLength ¶
func (*RdbReader) ReadLength64 ¶
func (*RdbReader) ReadLength64P ¶
func (*RdbReader) ReadLengthP ¶
func (*RdbReader) ReadString ¶
func (*RdbReader) ReadStringP ¶
func (*RdbReader) ReadUint16 ¶
func (*RdbReader) ReadUint32 ¶
func (*RdbReader) ReadUint32BigEndian ¶
func (*RdbReader) ReadUint32P ¶
func (*RdbReader) ReadUint64 ¶
func (*RdbReader) ReadUint64BigEndian ¶
func (*RdbReader) ReadUint64P ¶
func (*RdbReader) ReadUint8P ¶
func (*RdbReader) ReadZipmapItem ¶
func (r *RdbReader) ReadZipmapItem(buf *util.SliceBuffer, readFree bool) []byte
func (*RdbReader) ReadZipmapItemP ¶
func (r *RdbReader) ReadZipmapItemP(buf *util.SliceBuffer, readFree bool) []byte
type SetParser ¶
type SetParser struct {
BaseParser
}
func (*SetParser) ExecCmd ¶
func (sp *SetParser) ExecCmd(cb RdbObjExecutor)
func (*SetParser) ReadBuffer ¶
type StreamParser ¶
type StreamParser struct {
BaseParser
}
stream redis5.0+ redis5.0 : RDBTypeStreamListPacks redis7.0 : RDBTypeStreamListPacks2 redis7.2 : RdbTypeStreamListPacks3
func (*StreamParser) ExecCmd ¶
func (sp *StreamParser) ExecCmd(cb RdbObjExecutor)
func (*StreamParser) ReadBuffer ¶
func (sp *StreamParser) ReadBuffer(lr *Loader)
type StringParser ¶
type StringParser struct {
BaseParser
}
string
func (*StringParser) ExecCmd ¶
func (sp *StringParser) ExecCmd(cb RdbObjExecutor)
func (*StringParser) ReadBuffer ¶
func (sp *StringParser) ReadBuffer(lr *Loader)
type ZSetParser ¶
type ZSetParser struct {
BaseParser
}
zset
func (*ZSetParser) ExecCmd ¶
func (zp *ZSetParser) ExecCmd(cb RdbObjExecutor)
func (*ZSetParser) ReadBuffer ¶
func (zp *ZSetParser) ReadBuffer(lr *Loader)
redis4.0(rdb8) : ziplist_entries <= 128 then ziplist; else zset2(skiplist) redis7.2(rdb11) : entries <= 128 then listpack; else zset2