Documentation
¶
Index ¶
- Constants
- type AuxObject
- type BaseObject
- type CallbackFunc
- type DBSizeObject
- type HashObject
- type IntsetDetail
- type ListObject
- type ListpackDetail
- type ModuleTypeObject
- type Quicklist2Detail
- type QuicklistDetail
- type RedisObject
- type SetObject
- type StreamConsumer
- type StreamEntry
- type StreamGroup
- type StreamId
- type StreamMessage
- type StreamNAck
- type StreamObject
- type StringObject
- type ZSetEntry
- type ZSetObject
- type ZiplistDetail
Constants ¶
const ( // StringType is redis string StringType = "string" // ListType is redis list ListType = "list" // SetType is redis set SetType = "set" // HashType is redis hash HashType = "hash" // ZSetType is redis sorted set ZSetType = "zset" // AuxType is redis metadata key-value pair AuxType = "aux" // DBSizeType is for RDB_OPCODE_RESIZEDB DBSizeType = "dbsize" // StreamType is a redis stream StreamType = "stream" )
const ( // StringEncoding for string StringEncoding = "string" // ListEncoding is formed by a length encoding and some string ListEncoding = "list" // SetEncoding is formed by a length encoding and some string SetEncoding = "set" // ZSetEncoding is formed by a length encoding and some string ZSetEncoding = "zset" // HashEncoding is formed by a length encoding and some string HashEncoding = "hash" // ZSet2Encoding is zset version2 which stores doubles in binary format ZSet2Encoding = "zset2" // ZipMapEncoding has been deprecated ZipMapEncoding = "zipmap" // ZipListEncoding stores data in contiguous memory ZipListEncoding = "ziplist" // IntSetEncoding is a ordered list of integers IntSetEncoding = "intset" // QuickListEncoding is a list of ziplist QuickListEncoding = "quicklist" // ListPackEncoding is a new replacement for ziplist ListPackEncoding = "listpack" // QuickList2Encoding is a list of listpack QuickList2Encoding = "quicklist2" )
const QuicklistNodeContainerPacked = 2
QuicklistNodeContainerPacked means node of quicklist is list pack
const QuicklistNodeContainerPlain = 1
QuicklistNodeContainerPlain means node of quicklist is normal string
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuxObject ¶ added in v1.0.2
type AuxObject struct { *BaseObject Value string }
AuxObject stores redis metadata
func (*AuxObject) MarshalJSON ¶ added in v1.0.2
MarshalJSON marshal []byte as string
type BaseObject ¶
type BaseObject struct { DB int `json:"db"` // DB is db index of redis object Key string `json:"key"` // Key is key of redis object Expiration *time.Time `json:"expiration,omitempty"` // Expiration is expiration time, expiration of persistent object is nil Size int `json:"size"` // Size is rdb value size in Byte Type string `json:"type"` // Type is one of string/list/set/hash/zset Encoding string `json:"encoding"` // Encoding is the exact encoding method Extra interface{} `json:"-"` // Extra stores more detail of encoding for memory profiler and other usages }
BaseObject is basement of redis object
func (*BaseObject) GetDBIndex ¶
func (o *BaseObject) GetDBIndex() int
GetDBIndex returns db index of object
func (*BaseObject) GetElemCount ¶
func (o *BaseObject) GetElemCount() int
GetElemCount returns number of elements in list/set/hash/zset
func (*BaseObject) GetEncoding ¶ added in v1.0.6
func (o *BaseObject) GetEncoding() string
GetEncoding returns encoding of object
func (*BaseObject) GetExpiration ¶
func (o *BaseObject) GetExpiration() *time.Time
GetExpiration returns expiration time, expiration of persistent object is nil
func (*BaseObject) GetSize ¶
func (o *BaseObject) GetSize() int
GetSize returns rdb value size in Byte
type CallbackFunc ¶
type CallbackFunc func(object RedisObject) bool
CallbackFunc process redis object
type DBSizeObject ¶ added in v1.0.2
type DBSizeObject struct { *BaseObject KeyCount uint64 TTLCount uint64 }
DBSizeObject stores db size metadata
func (*DBSizeObject) GetType ¶ added in v1.0.2
func (o *DBSizeObject) GetType() string
GetType returns redis object type
type HashObject ¶
type HashObject struct { *BaseObject Hash map[string][]byte }
HashObject stores a hash object
func (*HashObject) GetElemCount ¶
func (o *HashObject) GetElemCount() int
GetElemCount returns number of elements in list/set/hash/zset
func (*HashObject) GetType ¶
func (o *HashObject) GetType() string
GetType returns redis object type
func (*HashObject) MarshalJSON ¶
func (o *HashObject) MarshalJSON() ([]byte, error)
MarshalJSON marshal []byte as string
type IntsetDetail ¶ added in v1.0.6
type IntsetDetail struct {
RawStringSize int
}
IntsetDetail stores detail for intset
type ListObject ¶
type ListObject struct { *BaseObject Values [][]byte }
ListObject stores a list object
func (*ListObject) GetElemCount ¶
func (o *ListObject) GetElemCount() int
GetElemCount returns number of elements in list/set/hash/zset
func (*ListObject) GetType ¶
func (o *ListObject) GetType() string
GetType returns redis object type
func (*ListObject) MarshalJSON ¶
func (o *ListObject) MarshalJSON() ([]byte, error)
MarshalJSON marshal []byte as string
type ListpackDetail ¶ added in v1.0.11
type ListpackDetail struct {
RawStringSize int
}
ListpackDetail stores detail for listpack
type ModuleTypeObject ¶ added in v1.0.10
type ModuleTypeObject struct { *BaseObject ModuleType string Value interface{} }
ModuleTypeObject stores a module type object parsed by custom handler
func (*ModuleTypeObject) GetType ¶ added in v1.0.10
func (o *ModuleTypeObject) GetType() string
GetType returns module type name
func (*ModuleTypeObject) MarshalJSON ¶ added in v1.0.10
func (o *ModuleTypeObject) MarshalJSON() ([]byte, error)
MarshalJSON marshal []byte as string
type Quicklist2Detail ¶ added in v1.0.6
type Quicklist2Detail struct { // NodeEncodings means node of quicklist is QuicklistNodeContainerPlain or QuicklistNodeContainerPacked NodeEncodings []int // ListPackEntrySize stores sizes of each listPackEntry is node encoding is QuicklistNodeContainerPacked ListPackEntrySize [][]uint32 }
Quicklist2Detail stores detail for quicklist2
type QuicklistDetail ¶ added in v1.0.6
type QuicklistDetail struct { // ZiplistStruct stores each ziplist within quicklist ZiplistStruct [][][]byte }
QuicklistDetail stores detail for quicklist
type RedisObject ¶
type RedisObject interface { // GetType returns redis type of object: string/list/set/hash/zset GetType() string // GetKey returns key of object GetKey() string // GetDBIndex returns db index of object GetDBIndex() int // GetExpiration returns expiration time, expiration of persistent object is nil GetExpiration() *time.Time // GetSize returns rdb value size in Byte GetSize() int // GetElemCount returns number of elements in list/set/hash/zset GetElemCount() int // GetEncoding returns encoding of object GetEncoding() string }
RedisObject is interface for a redis object
type SetObject ¶
type SetObject struct { *BaseObject Members [][]byte }
SetObject stores a set object
func (*SetObject) GetElemCount ¶
GetElemCount returns number of elements in list/set/hash/zset
func (*SetObject) MarshalJSON ¶
MarshalJSON marshal []byte as string
type StreamConsumer ¶ added in v1.0.8
type StreamConsumer struct { Name string `json:"name"` SeenTime uint64 `json:"seenTime"` Pending []*StreamId `json:"pending,omitempty"` ActiveTime uint64 `json:"activeTime"` // since rdb11, see https://github.com/redis/redis/pull/11099 }
StreamConsumer is a consumer
type StreamEntry ¶ added in v1.0.8
type StreamEntry struct { FirstMsgId *StreamId `json:"firstMsgId"` Fields []string `json:"fields"` Msgs []*StreamMessage `json:"msgs"` }
StreamEntry is a node in the underlying radix tree of redis stream, of type listpacks, which contains several messages. There is no need to care about which entry the message belongs to when using it.
type StreamGroup ¶ added in v1.0.8
type StreamGroup struct { Name string `json:"name"` LastId *StreamId `json:"lastId"` Pending []*StreamNAck `json:"pending,omitempty"` Consumers []*StreamConsumer `json:"consumers,omitempty"` // EntriesRead is only valid in V2. The following comments are from redis to illustrate its use /*In a perfect world (CG starts at 0-0, no dels, no XGROUP SETID, ...), this is the total number of group reads. In the real world, the reasoning behind this value is detailed at the top comment of streamEstimateDistanceFromFirstEverEntry(). */ EntriesRead uint64 `json:"entriesRead,omitempty"` }
StreamGroup is a consumer group
type StreamId ¶ added in v1.0.8
StreamId is a 128-bit number composed of a milliseconds time and a sequence counter
func (*StreamId) MarshalText ¶ added in v1.0.8
type StreamMessage ¶ added in v1.0.8
type StreamMessage struct { Id *StreamId `json:"id"` Fields map[string]string `json:"fields"` Deleted bool `json:"deleted"` }
StreamMessage is a message item in stream
type StreamNAck ¶ added in v1.0.8
type StreamNAck struct { Id *StreamId `json:"id"` DeliveryTime uint64 `json:"deliveryTime"` DeliveryCount uint64 `json:"deliveryCount"` }
StreamNAck points a pending message
type StreamObject ¶ added in v1.0.8
type StreamObject struct { *BaseObject // Version 2 means is RDB_TYPE_STREAM_LISTPACKS_2, 3 means is RDB_TYPE_STREAM_LISTPACKS_3 Version uint `json:"version,omitempty"` // Entries stores messages in stream Entries []*StreamEntry `json:"entries,omitempty"` // Groups is consumer groups of stream Groups []*StreamGroup `json:"groups,omitempty"` // Length is current number of messages inside this stream Length uint64 `json:"len"` // LastId is the ID of last entry in stream LastId *StreamId `json:"lastId"` // FirstId is the ID of first entry in stream. only valid in V2 FirstId *StreamId `json:"firstId,omitempty"` // MaxDeletedId is the maximal ID that was deleted in stream. only valid in V2 MaxDeletedId *StreamId `json:"maxDeletedId,omitempty"` // AddedEntriesCount is count of elements added in all time. only valid in V2 AddedEntriesCount uint64 `json:"addedEntriesCount,omitempty"` }
StreamObject stores a stream object
func (*StreamObject) GetType ¶ added in v1.0.8
func (obj *StreamObject) GetType() string
type StringObject ¶
type StringObject struct { *BaseObject Value []byte }
StringObject stores a string object
func (*StringObject) GetType ¶
func (o *StringObject) GetType() string
GetType returns redis object type
func (*StringObject) MarshalJSON ¶
func (o *StringObject) MarshalJSON() ([]byte, error)
MarshalJSON marshal []byte as string
type ZSetObject ¶
type ZSetObject struct { *BaseObject Entries []*ZSetEntry `json:"entries"` }
ZSetObject stores a sorted set object
func (*ZSetObject) GetElemCount ¶
func (o *ZSetObject) GetElemCount() int
GetElemCount returns number of elements in list/set/hash/zset
func (*ZSetObject) GetType ¶
func (o *ZSetObject) GetType() string
GetType returns redis object type
type ZiplistDetail ¶ added in v1.0.6
type ZiplistDetail struct {
RawStringSize int
}
ZiplistDetail stores detail for ziplist