Documentation
¶
Overview ¶
Package rdb parses RDB dump files.
Index ¶
- Variables
- type Aux
- type BloomFilter
- type CuckooFilter
- type DataKey
- type DatabaseSize
- type HashData
- type HashEntry
- type HashHead
- type HashValue
- type IntSetEncodingError
- type LengthEncodingError
- type ListData
- type ListEntry
- type ListHead
- type ModuleOpcodeError
- type Parser
- type SetData
- type SetEntry
- type SetHead
- type SortedSetData
- type SortedSetEntry
- type SortedSetHead
- type SortedSetValue
- type StringData
- type StringEncodingError
- type UnexpectedZipMapEndError
- type UnsupportedDataTypeError
- type UnsupportedVersionError
- type ZipListEndError
- type ZipListHeaderError
- type ZipListLengthError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidMagicString = errors.New("invalid magic string")
ErrInvalidMagicString is returned when a RDB dump file is not started with the magic string "REDIS".
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶ added in v0.6.0
type BloomFilter struct {
DataKey
}
BloomFilter represents a bloom filter data structure implemented by RedisBloom. At present, It only contains data key, but does not store the actual data values.
type CuckooFilter ¶ added in v0.6.0
type CuckooFilter struct {
DataKey
}
CuckooFilter represents a cuckoo filter data structure implemented by RedisBloom. At present, It only contains data key, but does not store the actual data values.
type DatabaseSize ¶ added in v0.1.1
type HashHead ¶
HashHead contains the key and the length of a hash. It is returned when a hash is read first time.
type IntSetEncodingError ¶
type IntSetEncodingError struct {
Encoding uint32
}
func (IntSetEncodingError) Error ¶
func (i IntSetEncodingError) Error() string
type LengthEncodingError ¶
type LengthEncodingError struct {
Encoding byte
}
func (LengthEncodingError) Error ¶
func (l LengthEncodingError) Error() string
type ListHead ¶
ListHead contains the key and the length of a list. It is returned when a list is read first time. The length may be incorrect when the list is backed by a quicklist data structure.
type ModuleOpcodeError ¶ added in v0.6.0
func (ModuleOpcodeError) Error ¶ added in v0.6.0
func (r ModuleOpcodeError) Error() string
type Parser ¶
Parser parses a RDB dump file.
Example (Basic) ¶
file, err := os.Open("dump.rdb") if err != nil { panic(err) } defer file.Close() parser := NewParser(file) for { data, err := parser.Next() if errors.Is(err, io.EOF) { break } if err != nil { panic(err) } switch data := data.(type) { case *StringData: fmt.Println(data.Key, data.Value) case *ListData: for i, value := range data.Value { fmt.Println(data.Key, i, value) } } }
Example (KeyFilter) ¶
file, err := os.Open("dump.rdb") if err != nil { panic(err) } defer file.Close() parser := NewParser(file) parser.KeyFilter = func(key *DataKey) bool { return key.Database == 0 && strings.HasPrefix(key.Key, "foo:") && !key.Expired() }
func (*Parser) Next ¶
Next reads data from the reader until the next token and returns one of the following types:
*Aux *DatabaseSize *StringData *ListHead, *ListEntry, *ListData *SetHead, *SetEntry, *SetData *SortedSetHead, *SortedSetEntry, *SortedSetData *MapHead, *MapEntry, *MapData
Next returns a io.EOF error when a EOF token is read.
type SetHead ¶
SetHead contains the key and the length of a set. It is returned when a set is read first time.
type SortedSetData ¶
type SortedSetData struct { DataKey Value []SortedSetValue }
SortedSetData is returned when all entries in a sorted set are all read.
type SortedSetEntry ¶
type SortedSetEntry struct { DataKey SortedSetValue Index int Length int }
SortedSetEntry is returned when a new sorted set entry is read.
type SortedSetHead ¶
SortedSetHead contains the key and the length of a sorted set. It is returned when a sorted set is read first time.
type SortedSetValue ¶
SortedSetValue contains the value and its score of a sorted set entry.
type StringData ¶
StringData contains the key and the value of string data.
type StringEncodingError ¶
type StringEncodingError struct {
Encoding int
}
func (StringEncodingError) Error ¶
func (s StringEncodingError) Error() string
type UnexpectedZipMapEndError ¶
type UnexpectedZipMapEndError struct {
Key string
}
func (UnexpectedZipMapEndError) Error ¶
func (u UnexpectedZipMapEndError) Error() string
type UnsupportedDataTypeError ¶
type UnsupportedDataTypeError struct {
DataType byte
}
func (UnsupportedDataTypeError) Error ¶
func (u UnsupportedDataTypeError) Error() string
type UnsupportedVersionError ¶
type UnsupportedVersionError struct {
Version int
}
func (UnsupportedVersionError) Error ¶
func (u UnsupportedVersionError) Error() string
type ZipListEndError ¶ added in v0.1.1
type ZipListEndError struct {
Value byte
}
func (ZipListEndError) Error ¶ added in v0.1.1
func (z ZipListEndError) Error() string
type ZipListHeaderError ¶
type ZipListHeaderError struct {
Header byte
}
func (ZipListHeaderError) Error ¶
func (z ZipListHeaderError) Error() string
type ZipListLengthError ¶ added in v0.1.1
func (ZipListLengthError) Error ¶ added in v0.1.1
func (z ZipListLengthError) Error() string