Documentation
¶
Index ¶
- Constants
- type Decoder
- func (d *Decoder) Aux(key, value []byte)
- func (d *Decoder) EndHash(key []byte)
- func (d *Decoder) EndList(key []byte)
- func (d *Decoder) EndRDB()
- func (d *Decoder) EndSet(key []byte)
- func (d *Decoder) EndStream(key []byte, items uint64, lastEntryID string, cgroupsData rdb.StreamGroups)
- func (d *Decoder) EndZSet(key []byte)
- func (d *Decoder) GetTimestamp() int64
- func (d *Decoder) GetUsedMem() int64
- func (d *Decoder) Hset(key, field, value []byte)
- func (d *Decoder) Rpush(key, value []byte, NodeEncodings uint64)
- func (d *Decoder) Sadd(key, member []byte)
- func (d *Decoder) Set(key, value []byte, expiry int64, info *rdb.Info)
- func (d *Decoder) StartDatabase(n int)
- func (d *Decoder) StartHash(key []byte, length, expiry int64, info *rdb.Info)
- func (d *Decoder) StartList(key []byte, length, expiry int64, info *rdb.Info)
- func (d *Decoder) StartRDB(ver int)
- func (d *Decoder) StartSet(key []byte, cardinality, expiry int64, info *rdb.Info)
- func (d *Decoder) StartStream(key []byte, cardinality, expiry int64, info *rdb.Info)
- func (d *Decoder) StartZSet(key []byte, cardinality, expiry int64, info *rdb.Info)
- func (d *Decoder) Xadd(key, id, listpack []byte)
- func (d *Decoder) Zadd(key []byte, score float64, member []byte)
- type Entry
- type MemProfiler
- func (m *MemProfiler) ElemLen(element []byte) uint64
- func (m *MemProfiler) HashTableEntryOverHead() uint64
- func (m *MemProfiler) HashTableOverHead(size uint64) uint64
- func (m *MemProfiler) KeyExpiryOverhead(expiry int64) uint64
- func (m *MemProfiler) LinkedListEntryOverHead() uint64
- func (m *MemProfiler) LinkedListOverHead() uint64
- func (m *MemProfiler) ListPackEntryOverHead() uint64
- func (m *MemProfiler) QuickList2OverHead() uint64
- func (m *MemProfiler) QuickListOverHead(size uint64) uint64
- func (m *MemProfiler) RobjOverHead() uint64
- func (m *MemProfiler) SizeofStreamRadixTree(numElements uint64) uint64
- func (m *MemProfiler) SizeofString(bytes []byte) uint64
- func (m *MemProfiler) SkipListEntryOverHead() uint64
- func (m *MemProfiler) SkipListOverHead(size uint64) uint64
- func (m *MemProfiler) StreamCG() uint64
- func (m *MemProfiler) StreamConsumer(name []byte) uint64
- func (m *MemProfiler) StreamNACK(length uint64) uint64
- func (m *MemProfiler) StreamOverhead() uint64
- func (m *MemProfiler) TopLevelObjOverhead(key []byte, expiry int64) uint64
- func (m *MemProfiler) ZipListEntryOverHead(value []byte) uint64
- func (m *MemProfiler) ZipListHeaderOverHead() uint64
Constants ¶
const LRU_BITS = 24
RobjOverHead get memory usage of a robj
typedef struct redisobject {
unsigned type:4;
unsigned encoding:4;
unsigned lru:lru_bits; /* lru time (relative to server.lruclock) */
int refcount;
void *ptr;
} robj;
在 Redis 的底层实现中,每个键值对都对应一个 redisObject 结构,该结构包含一个 lru 字段,用于记录对象最后一次被访问的时间戳。默认值是 24 个比特位
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
Entries chan *Entry
Db int
nopdecoder.NopDecoder
// contains filtered or unexported fields
}
Decoder decode rdb file
func (*Decoder) EndRDB ¶
func (d *Decoder) EndRDB()
EndRDB is called when parsing of the RDB file is complete.
func (*Decoder) GetTimestamp ¶
func (*Decoder) GetUsedMem ¶
func (*Decoder) StartDatabase ¶
func (*Decoder) StartHash ¶
StartHash is called at the beginning of a hash. Hset will be called exactly length times before EndHash.
func (*Decoder) StartList ¶
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
func (*Decoder) StartSet ¶
StartSet is called at the beginning of a set. Sadd will be called exactly cardinality times before EndSet.
func (*Decoder) StartStream ¶
type Entry ¶
type Entry struct {
Key string
Bytes uint64
Type string
NumOfElem uint64
LenOfLargestElem uint64
FieldOfLargestElem string
Db int
Encoding string
Expiration int64
LruIdle uint64
LfuFreq int
}
Entry is info of a redis recored
type MemProfiler ¶
type MemProfiler struct{}
MemProfiler get memory use for all kinds of data stuct
func (*MemProfiler) ElemLen ¶
func (m *MemProfiler) ElemLen(element []byte) uint64
ElemLen get length of a element
func (*MemProfiler) HashTableEntryOverHead ¶
func (m *MemProfiler) HashTableEntryOverHead() uint64
HashTableEntryOverHead get memory use of hashtable entry See https://github.com/antirez/redis/blob/unstable/src/dict.h Each dictEntry has 3 pointers
typedef struct dictEntry {
void *key;
union {
void *val;
uint64_t u64;
int64_t s64;
double d;
} v;
struct dictEntry *next;
} dictEntry;
func (*MemProfiler) HashTableOverHead ¶
func (m *MemProfiler) HashTableOverHead(size uint64) uint64
HashTableOverhead get memory use of a hashtable See https://github.com/antirez/redis/blob/unstable/src/dict.h See the structures dict and dictht 2 * (3 unsigned longs + 1 pointer) + int + long + 2 pointers
Additionally, see **table in dictht The length of the table is the next power of 2 When the hashtable is rehashing, another instance of **table is created Due to the possibility of rehashing during loading, we calculate the worse case in which both tables are allocated, and so multiply the size of **table by 1.5
func (*MemProfiler) KeyExpiryOverhead ¶
func (m *MemProfiler) KeyExpiryOverhead(expiry int64) uint64
KeyExpiryOverhead get memory usage of a key expiry Key expiry is stored in a hashTable, so we have to pay for the cost of a hashTable entry The timestamp itself is stored as an int64, which is a 8 bytes
func (*MemProfiler) LinkedListEntryOverHead ¶
func (m *MemProfiler) LinkedListEntryOverHead() uint64
LinkedListEntryOverHead get memory use of a linked list entry See https://github.com/antirez/redis/blob/unstable/src/adlist.h A node has 3 pointers
func (*MemProfiler) LinkedListOverHead ¶
func (m *MemProfiler) LinkedListOverHead() uint64
LinkedListOverHead get memory use of a linked list See https://github.com/antirez/redis/blob/unstable/src/adlist.h A list has 5 pointers + an unsigned long
func (*MemProfiler) ListPackEntryOverHead ¶ added in v1.0.5
func (m *MemProfiler) ListPackEntryOverHead() uint64
func (*MemProfiler) QuickList2OverHead ¶ added in v1.0.5
func (m *MemProfiler) QuickList2OverHead() uint64
func (*MemProfiler) QuickListOverHead ¶
func (m *MemProfiler) QuickListOverHead(size uint64) uint64
func (*MemProfiler) RobjOverHead ¶
func (m *MemProfiler) RobjOverHead() uint64
func (*MemProfiler) SizeofStreamRadixTree ¶
func (m *MemProfiler) SizeofStreamRadixTree(numElements uint64) uint64
func (*MemProfiler) SizeofString ¶
func (m *MemProfiler) SizeofString(bytes []byte) uint64
SizeofString get memory use of a string https://github.com/antirez/redis/blob/unstable/src/sds.h
func (*MemProfiler) SkipListEntryOverHead ¶
func (m *MemProfiler) SkipListEntryOverHead() uint64
SkipListEntryOverHead get memory use of a skiplist entry
func (*MemProfiler) SkipListOverHead ¶
func (m *MemProfiler) SkipListOverHead(size uint64) uint64
SkipListOverHead get memory use of a skiplist
func (*MemProfiler) StreamCG ¶
func (m *MemProfiler) StreamCG() uint64
func (*MemProfiler) StreamConsumer ¶
func (m *MemProfiler) StreamConsumer(name []byte) uint64
func (*MemProfiler) StreamNACK ¶
func (m *MemProfiler) StreamNACK(length uint64) uint64
func (*MemProfiler) StreamOverhead ¶
func (m *MemProfiler) StreamOverhead() uint64
func (*MemProfiler) TopLevelObjOverhead ¶
func (m *MemProfiler) TopLevelObjOverhead(key []byte, expiry int64) uint64
TopLevelObjOverhead get memory use of a top level object Each top level object is an entry in a dictionary, and so we have to include the overhead of a dictionary entry
func (*MemProfiler) ZipListEntryOverHead ¶
func (m *MemProfiler) ZipListEntryOverHead(value []byte) uint64
func (*MemProfiler) ZipListHeaderOverHead ¶
func (m *MemProfiler) ZipListHeaderOverHead() uint64