Documentation
¶
Overview ¶
Package rdb implements parsing and encoding of the Redis RDB file format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder interface {
// StartRDB is called when parsing of a valid RDB file starts.
StartRDB(ver int)
// StartDatabase is called when database n starts.
// Once a database starts, another database will not start until EndDatabase is called.
StartDatabase(n int)
// AUX field
Aux(key, value []byte)
// ResizeDB hint
ResizeDatabase(dbSize, expiresSize uint32)
// Set is called once for each string key.
Set(key, value []byte, expiry int64, info *Info)
// StartHash is called at the beginning of a hash.
// Hset will be called exactly length times before EndHash.
StartHash(key []byte, length, expiry int64, info *Info)
// Hset is called once for each field=value pair in a hash.
Hset(key, field, value []byte)
// EndHash is called when there are no more fields in a hash.
EndHash(key []byte)
// StartSet is called at the beginning of a set.
// Sadd will be called exactly cardinality times before EndSet.
StartSet(key []byte, cardinality, expiry int64, info *Info)
// Sadd is called once for each member of a set.
Sadd(key, member []byte)
// EndSet is called when there are no more fields in a set.
EndSet(key []byte)
// StartStream is called at the beginning of a stream.
// Xadd will be called exactly length times before EndStream.
StartStream(key []byte, cardinality, expiry int64, info *Info)
// Xadd is called once for each id in a stream.
Xadd(key, id, listpack []byte)
// EndHash is called when there are no more fields in a hash.
EndStream(key []byte, items uint64, lastEntryID string, cgroupsData StreamGroups)
// StartList is called at the beginning of a list.
// Rpush will be called exactly length times before EndList.
// If length of the list is not known, then length is -1
StartList(key []byte, length, expiry int64, info *Info)
// Rpush is called once for each value in a list.
// rdb v1.0.8增加NodeEncodings是为了支持redis7+的Quicklist2,qucklist2中节点有两种编码1和2,其他数据类型传0
Rpush(key, value []byte, NodeEncodings uint64)
// EndList is called when there are no more values in a list.
EndList(key []byte)
// StartZSet is called at the beginning of a sorted set.
// Zadd will be called exactly cardinality times before EndZSet.
StartZSet(key []byte, cardinality, expiry int64, info *Info)
// Zadd is called once for each member of a sorted set.
Zadd(key []byte, score float64, member []byte)
// EndZSet is called when there are no more members in a sorted set.
EndZSet(key []byte)
// EndDatabase is called at the end of a database.
EndDatabase(n int)
// EndRDB is called when parsing of the RDB file is complete.
EndRDB()
}
A Decoder must be implemented to parse a RDB file.
type StreamConsumerData ¶ added in v1.0.3
type StreamConsumerData struct {
Name []byte
SeenTime uint64
Pending []*StreamConsumerPendingEntry
ActiveTime uint64
}
type StreamConsumerPendingEntry ¶ added in v1.0.3
type StreamConsumerPendingEntry struct {
ID []byte
}
type StreamGroup ¶ added in v1.0.3
type StreamGroup struct {
Name []byte
LastEntryId string
Pending []*StreamPendingEntry
Consumers []*StreamConsumerData
}
type StreamGroups ¶ added in v1.0.3
type StreamGroups []*StreamGroup
type StreamId ¶ added in v1.0.8
rdd v1.0.8 2026-01-09 add stream 消息队列 支持redis7增加的两个存储类型TypeStreamListPacks2=19,rdbTypeStreamListpacks3=21 此部分参考的 github.com/linyue515/rdr 等有精力和时间了,再对比RedisShake进行梳理改善
type StreamPendingEntry ¶ added in v1.0.3
type ValueType ¶
type ValueType byte
ValueType of redis type
const ( TypeString ValueType = 0 // RDB_TYPE_STRING TypeList ValueType = 1 TypeSet ValueType = 2 TypeZSet ValueType = 3 TypeHash ValueType = 4 // RDB_TYPE_HASH TypeZSet2 ValueType = 5 // ZSET version 2 with doubles stored in binary. TypeModule ValueType = 6 // RDB_TYPE_MODULE TypeModule2 ValueType = 7 // RDB_TYPE_MODULE2 Module value with annotations for parsing without the generating module being loaded. // Object types for encoded objects. TypeHashZipMap ValueType = 9 TypeListZipList ValueType = 10 TypeSetIntSet ValueType = 11 TypeZSetZipList ValueType = 12 TypeHashZipList ValueType = 13 TypeListQuickList ValueType = 14 // RDB_TYPE_LIST_QUICKLIST TypeStreamListPacks ValueType = 15 // RDB_TYPE_STREAM_LISTPACKS, //rdb v1.0.5 add,注:Redis Stream 主要用于消息队列,虽然我们一般不会用它,参考 github.com/linyue515/rdr 做了支持,后期有精力时间时再参考RedisShake进行梳理 TypeHashListPack ValueType = 16 // RDB_TYPE_HASH_ZIPLIST TypeZSetListPack ValueType = 17 // RDB_TYPE_ZSET_LISTPACK TypeListQuickList2 ValueType = 18 // DB_TYPE_LIST_QUICKLIST_2 https://github.com/redis/redis/pull/9357 TypeStreamListPacks2 ValueType = 19 // RDB_TYPE_STREAM_LISTPACKS2 TypeSetListPack ValueType = 20 // RDB_TYPE_SET_LISTPACK TypeStreamListPacks3 ValueType = 21 // RDB_TYPE_STREAM_LISTPACKS_3 // https://github.com/redis/redis/pull/13391 TypeHashMetadataPreGa ValueType = 22 // RDB_TYPE_HASH_METADATA_PRE_GA TypeHashListPackExPre ValueType = 23 // RDB_TYPE_HASH_LISTPACK_EX_PRE_GA TypeHashMetaData ValueType = 24 // RDB_TYPE_HASH_METADATA TypeHashListPackEx ValueType = 25 // RDB_TYPE_HASH_LISTPACK_EX )
types value string: TypeString list: TypeList, TypeListZipList, TypeListQuickList, TypeListQuickList2 set: TypeSet, TypeSetIntSet, TypeSetListPack Sorted Set(zset): TypeZSet, TypeZSet2, TypeZSetZipList, TypeZSetListPack hash: TypeHash, TypeHashZipMap, TypeHashZipList, TypeHashListPack, TypeHashMetadataPreGa, TypeHashListPackExPre, TypeHashMetaData, TypeHashListPackEx 注:Redis7.0开始使用listpack替代了ziplist,小于阈值时使用listpack
Directories
¶
| Path | Synopsis |
|---|---|
|
core
|
|
|
Package crc64 implements the Jones coefficients with an init value of 0.
|
Package crc64 implements the Jones coefficients with an init value of 0. |
|
This is a very basic example of a program that implements rdb.decoder and outputs a human readable diffable dump of the rdb file.
|
This is a very basic example of a program that implements rdb.decoder and outputs a human readable diffable dump of the rdb file. |
|
internal
|
|
