dump

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

This code is mostly copied from Beego BeeMap

Index

Constants

View Source
const (
	DefaultTopBigKeyNum               = 500
	DefaultSeparators                 = ":;,_- "
	DefaultStoreAllPrefixes           = false
	DefaultTopPrefixNum               = 500
	DefaultPrefixPreShrinkNum         = 5000
	DefaultPrefixContainerMaxCapacity = 50000
)

v1.1.4 add

Variables

This section is empty.

Functions

func Decode

func Decode(c *cli.Context, decoder *decoder.Decoder, filepath string)

Decode ...

func Dump

func Dump(path string) (map[string]interface{}, error)

Dump rdb file statistical information, 此方法不再用了,因为有了输出到STDOUT 或 file

func Export_All_Keys added in v1.1.3

func Export_All_Keys(cli *cli.Context)

keys is function for command `keys` output all keys in rdb file(s) get from args

func GetData

func GetData(filename string, cnt *Counter, topN int, sizeFilter int64) map[string]interface{}

func InitHTMLTmpl

func InitHTMLTmpl()

func Key

func Key(key string) string

func ParseUnitToBytes added in v1.1.3

func ParseUnitToBytes(sizeStr string) (int64, error)

将带单位的字符串转换为字节数

func ServeHTML

func ServeHTML(w http.ResponseWriter, layout string, content string, data map[string]interface{})

ServeHTML generate and write html to client

func Show

func Show(c *cli.Context)

Show parse rdbfile(s) and show statistical information by html

func Slot

func Slot(key string) int

hashSlot returns a consistent slot number between 0 and 16383 for any given string key.

func ToCliWriter

func ToCliWriter(cli *cli.Context)

ToCliWriter dump rdb file statistical information to STDOUT.

func ToCliWriterToFile added in v1.0.6

func ToCliWriterToFile(cli *cli.Context)

ToCliWriter dump rdb file statistical information to file.

Types

type Counter

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

Counter for redis memory usage

func NewCounter

func NewCounter(config *CounterConfig) *Counter

NewCounter return a pointer of Counter

func (*Counter) Count

func (c *Counter) Count(in <-chan *decoder.Entry)

Count by various dimensions,show.go NewCounter 后,调用此方法,遍历decoder的entry, <-chan表示一个只能接收数据的单向通道

func (*Counter) GetLargestEntries

func (c *Counter) GetLargestEntries(num int, sizeFilter int64) []*decoder.Entry

GetLargestEntries from heap, num max is 500. 过滤掉小于阈值的key

func (*Counter) GetLargestKeyPrefixes

func (c *Counter) GetLargestKeyPrefixes() []*PrefixEntry

GetLargestKeyPrefixes from heap

func (*Counter) GetLenLevelCount

func (c *Counter) GetLenLevelCount() []*PrefixEntry

GetLenLevelCount from map

type CounterConfig added in v1.1.4

type CounterConfig struct {

	// Bigkey数量阈值,默认 500
	TopBigKeyNum int

	// key前缀分隔符,默认 ":;,_- "
	Separators string
	// 是否存储所有前缀,仅当你的主机内存足够时开启,默认关闭
	// false时,对前缀的存储量进行动态收缩, 前缀个数越多,创建的对象也就越多,从而耗内存就越多,就会因内存不足执行不完, 详见 https://github.com/919927181/rdr/issues/1
	StoreAllPrefixes bool
	// 前缀数量阈值,默认 500
	TopPrefixNum int
	// 前缀容器的最大容量,默认值为前缀数量阈值的10倍,可以理解为最大水位线,到达最大水位线,就要去排出一部分水
	PrefixContainerMaxCapacity int
	// 前缀容器的预缩容数量,可以理解为正常水位线
	PrefixPreShrinkNum int
}

v1.1.4 add

func NewCounterConfig added in v1.1.4

func NewCounterConfig() *CounterConfig

默认配置, v1.1.4 add

type PrefixEntry

type PrefixEntry struct {
	Bytes uint64
	Num   uint64
	Db    string //之前为int
	// contains filtered or unexported fields
}

PrefixEntry record value by prefix

type SafeMap

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

SafeMap is a map which concurrency safe

func NewSafeMap

func NewSafeMap() *SafeMap

NewSafeMap return new safemap

func (*SafeMap) Check

func (m *SafeMap) Check(k interface{}) bool

Check seturns true if k is exist in the map.

func (*SafeMap) Delete

func (m *SafeMap) Delete(k interface{})

Delete the given key and value.

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.

func (*SafeMap) Set

func (m *SafeMap) Set(k interface{}, v interface{}) bool

Set the given key and value. Returns false if the key is already in the map and changes nothing.

func (*SafeMap) String

func (m *SafeMap) String() (s string)

String transfer map into json

type SlotEntry

type SlotEntry struct {
	Slot int
	Size uint64
}

support for sorting of slots

Jump to

Keyboard shortcuts

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