Documentation ¶
Overview ¶
This code is mostly copied from Beego BeeMap
Index ¶
- Variables
- func Index(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func InitHTMLTmpl()
- func RdbReveal(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func ServeHTML(w http.ResponseWriter, layout string, content string, ...)
- type Counter
- type Decoder
- 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) EndZSet(key []byte)
- func (d *Decoder) Hset(key, field, value []byte)
- func (d *Decoder) Rpush(key, value []byte)
- func (d *Decoder) Sadd(key, member []byte)
- func (d *Decoder) Set(key, value []byte, expiry int64)
- func (d *Decoder) StartHash(key []byte, length, expiry int64)
- func (d *Decoder) StartList(key []byte, length, expiry int64)
- func (d *Decoder) StartSet(key []byte, cardinality, expiry int64)
- func (d *Decoder) StartZSet(key []byte, cardinality, expiry int64)
- 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) RobjOverhead() uint64
- func (m *MemProfiler) SizeofString(bytes []byte) uint64
- func (m *MemProfiler) SkiplistEntryOverhead() uint64
- func (m *MemProfiler) SkiplistOverhead(size uint64) uint64
- func (m *MemProfiler) TopLevelObjOverhead() uint64
- type PrefixEntry
- type SafeMap
Constants ¶
This section is empty.
Variables ¶
var Counters = NewSafeMap()
var (
TplCommonData = map[string]interface{}{}
)
Functions ¶
func Index ¶
func Index(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func InitHTMLTmpl ¶
func InitHTMLTmpl()
func RdbReveal ¶
func RdbReveal(w http.ResponseWriter, r *http.Request, p httprouter.Params)
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter for redis memory useage
func (*Counter) GetLargestEntries ¶
GetLargestEntries from heap, num max is 500
func (*Counter) GetLargestKeyPrefixes ¶
func (c *Counter) GetLargestKeyPrefixes() []*PrefixEntry
GetLargestKeyPrefixes from heap
func (*Counter) GetLenLevelCount ¶
func (c *Counter) GetLenLevelCount() []*PrefixEntry
GetLenLevelCount from map
type Decoder ¶
type Decoder struct { Entries chan *Entry 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) 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.
type Entry ¶
type Entry struct { Key string Bytes uint64 Type string NumOfElem uint64 LenOfLargestElem uint64 FieldOfLargestElem string }
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 2 pointers + int64
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 useage 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) RobjOverhead ¶
func (m *MemProfiler) RobjOverhead() uint64
RobjOverhead get memory useage of a robj
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) TopLevelObjOverhead ¶
func (m *MemProfiler) TopLevelObjOverhead() 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
type PrefixEntry ¶
PrefixEntry record value by prefix
type SafeMap ¶
type SafeMap struct {
// contains filtered or unexported fields
}
SafeMap is a map which concurrency safe
func (*SafeMap) Get ¶
func (m *SafeMap) Get(k interface{}) interface{}
Get from maps return the k's value
func (*SafeMap) Items ¶
func (m *SafeMap) Items() map[interface{}]interface{}
Items returns all items in safemap.