Help us shape the future of Go! Take the 2026 Go Developer Survey

rdb

package module
v0.0.0-...-2749217 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: MIT Imports: 10 Imported by: 0

README

rdb

Forked from cupcake/rdb.

rdb is a Go package that implements parsing and encoding of the Redis RDB file format.

This package was heavily inspired by redis-rdb-tools by Sripathi Krishnan.

Original Documentation

Installation

go get github.com/groove-x/rdb

Documentation

Overview

Package rdb implements parsing and encoding of the Redis RDB file format.

Index

Constants

View Source
const Version = 6

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, d Decoder) error

Decode parses a RDB file from r and calls the decode hooks on d.

Types

type Decoder

type Decoder interface {
	// StartRDB is called when parsing of a valid RDB file starts.
	StartRDB()
	// StartDatabase is called when database n starts.
	// Once a database starts, another database will not start until EndDatabase is called.
	StartDatabase(n int, offset 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)
	// StartHash is called at the beginning of a hash.
	// Hset will be called exactly length times before EndHash.
	StartHash(key []byte, length, expiry int64)
	// 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)
	// 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)
	// 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)
	// Rpush is called once for each value in a list.
	Rpush(key, value []byte)
	// EndList is called when there are no more values in a list.
	EndList(key []byte)
	StartQuickList(key []byte, expiry int64)
	EndQuickList(key []byte, length int64)
	// 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)
	// 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, offset int)
	// EndRDB is called when parsing of the RDB file is complete.
	EndRDB(offset int)
}

A Decoder must be implemented to parse a RDB file.

type Encoder

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

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) EncodeDatabase

func (e *Encoder) EncodeDatabase(n int) error

func (*Encoder) EncodeDumpFooter

func (e *Encoder) EncodeDumpFooter() error

func (*Encoder) EncodeExpiry

func (e *Encoder) EncodeExpiry(expiry uint64) error

func (*Encoder) EncodeFloat

func (e *Encoder) EncodeFloat(f float64) (err error)

func (*Encoder) EncodeFooter

func (e *Encoder) EncodeFooter() error

func (*Encoder) EncodeHeader

func (e *Encoder) EncodeHeader() error

func (*Encoder) EncodeLength

func (e *Encoder) EncodeLength(l uint32) (err error)

func (*Encoder) EncodeString

func (e *Encoder) EncodeString(s []byte) error

func (*Encoder) EncodeType

func (e *Encoder) EncodeType(v ValueType) error

type ValueType

type ValueType byte
const (
	TypeString ValueType = 0
	TypeList   ValueType = 1
	TypeSet    ValueType = 2
	TypeZSet   ValueType = 3
	TypeHash   ValueType = 4
	TypeZSet2  ValueType = 5
	TypeModule ValueType = 6

	TypeHashZipmap    ValueType = 9
	TypeListZiplist   ValueType = 10
	TypeSetIntset     ValueType = 11
	TypeZSetZiplist   ValueType = 12
	TypeHashZiplist   ValueType = 13
	TypeListQuicklist ValueType = 14
)

Directories

Path Synopsis
Package crc64 implements the Jones coefficients with an init value of 0.
Package crc64 implements the Jones coefficients with an init value of 0.
examples
diff command
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.
split_databases command

Jump to

Keyboard shortcuts

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