core

package
v0.0.0-...-9d83beb Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

Package core is RDB core core

Index

Constants

View Source
const (
	OpcodeEOF    = 0
	OpcodeSInt   = 1
	OpcodeUInt   = 2
	OpcodeFloat  = 3
	OpcodeDouble = 4
	OpcodeString = 5
)
View Source
const (
	// StreamItemFlagNone means No special flags.
	StreamItemFlagNone = 0
	// StreamItemFlagDeleted means entry was deleted
	StreamItemFlagDeleted = 1 << 0
	// StreamItemFlagSameFields means entry has the same fields as the master entry
	StreamItemFlagSameFields = 1 << 1
)
View Source
const ModuleTypeNameCharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"

Variables

This section is empty.

Functions

func RandString

func RandString(n int) string

RandString create a random string no longer than n

Types

type Decoder

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

Decoder is an instance of rdb parsing process

func NewDecoder

func NewDecoder(reader io.Reader) *Decoder

NewDecoder creates a new RDB decoder

func (*Decoder) GetReadCount

func (dec *Decoder) GetReadCount() int

func (*Decoder) Parse

func (dec *Decoder) Parse(cb func(object model.RedisObject) bool) (err error)

Parse parses rdb and callback cb returns true to continue, returns false to stop the iteration

func (*Decoder) WithSpecialOpCode

func (dec *Decoder) WithSpecialOpCode() *Decoder

WithSpecialOpCode enables returning model.AuxObject to callback

func (*Decoder) WithSpecialType

func (dec *Decoder) WithSpecialType(moduleType string, f ModuleTypeHandleFunc) *Decoder

type Encoder

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

Encoder is used to generate RDB file

func NewEncoder

func NewEncoder(writer io.Writer) *Encoder

NewEncoder creates an encoder instance

func (*Encoder) EnableCompress

func (enc *Encoder) EnableCompress() *Encoder

remain unfixed bugs, don't open

func (*Encoder) SetHashZipListOpt

func (enc *Encoder) SetHashZipListOpt(maxValue, maxEntries int) *Encoder

SetHashZipListOpt sets hash-max-ziplist-value and hash-max-ziplist-entries

func (*Encoder) SetListZipListOpt

func (enc *Encoder) SetListZipListOpt(maxValue, maxEntries int) *Encoder

SetListZipListOpt sets list-max-ziplist-value and list-max-ziplist-entries

func (*Encoder) SetZSetZipListOpt

func (enc *Encoder) SetZSetZipListOpt(maxValue, maxEntries int) *Encoder

SetZSetZipListOpt sets zset-max-ziplist-value and zset-max-ziplist-entries

func (*Encoder) WriteAux

func (enc *Encoder) WriteAux(key, value string) error

WriteAux writes aux object

func (*Encoder) WriteDBHeader

func (enc *Encoder) WriteDBHeader(dbIndex uint, keyCount, ttlCount uint64) error

WriteDBHeader write db index and resize db into rdb file

func (*Encoder) WriteEnd

func (enc *Encoder) WriteEnd() error

WriteEnd writes EOF and crc sum

func (*Encoder) WriteHashMapObject

func (enc *Encoder) WriteHashMapObject(key string, hash map[string][]byte, options ...interface{}) error

func (*Encoder) WriteHeader

func (enc *Encoder) WriteHeader() error

func (*Encoder) WriteListObject

func (enc *Encoder) WriteListObject(key string, values [][]byte, options ...interface{}) error

func (*Encoder) WriteSetObject

func (enc *Encoder) WriteSetObject(key string, values [][]byte, options ...interface{}) error

func (*Encoder) WriteStringObject

func (enc *Encoder) WriteStringObject(key string, value []byte, options ...interface{}) error

func (*Encoder) WriteZSetObject

func (enc *Encoder) WriteZSetObject(key string, entries []*model.ZSetEntry, options ...interface{}) error

type ModuleTypeHandleFunc

type ModuleTypeHandleFunc func(handler ModuleTypeHandler, encVersion int) (interface{}, error)

type ModuleTypeHandler

type ModuleTypeHandler interface {
	ReadByte() (byte, error)
	ReadFull(buf []byte) error
	ReadString() ([]byte, error)
	ReadLength() (uint64, bool, error)
}

type TTLOption

type TTLOption uint64

TTLOption specific expiration timestamp for object

func WithTTL

func WithTTL(expirationMs uint64) TTLOption

WithTTL specific expiration timestamp for object

Jump to

Keyboard shortcuts

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