Documentation ¶
Index ¶
- Variables
- func GetAllMastersAddr(sarr map[string]*ClusterNodeInfo) []string
- func GetAllSlavesAddr(sarr map[string]*ClusterNodeInfo) []string
- func GetClusterNodesInfo(client *redis.ClusterClient) (map[string]*ClusterNodeInfo, error)
- func GetLatestSlaveOfMasters(masters []string) (map[string]string, []string, []string, error)
- func GetRedisAddr(host string, port int) string
- func GetRedisBigkeyHeader() string
- func ParseDBkeyspce(line string) (uint64, uint64, float64, error)
- func ParseInfoClient(result map[string]string, info *RedisInfoAll)
- func ParseInfoKeyspace(result map[string]string, info *RedisInfoAll)
- func ParseInfoMemory(result map[string]string, info *RedisInfoAll)
- func ParseInfoPersistent(result map[string]string, info *RedisInfoAll)
- func ParseInfoReplication(result map[string]string, info *RedisInfoAll)
- func ParseInfoSever(result map[string]string, info *RedisInfoAll)
- func ParseInfoStats(result map[string]string, info *RedisInfoAll)
- func ScanRedisKeys(client *redis.Client, scanCnt int64, matchRe *regexp.Regexp, sleepCnt int, ...) error
- type ClusterAndRedisClient
- func (client ClusterAndRedisClient) CheckIfCluster() (bool, error)
- func (client ClusterAndRedisClient) DeleteKeyList(key string, length int64, eachCnt int64, elementBatch int64, ...) error
- func (client ClusterAndRedisClient) DeleteKeyString(key string) error
- func (client ClusterAndRedisClient) DeleteKeysByDirectlyDelIt(keyes []string) error
- func (client ClusterAndRedisClient) DeleteKeysByExpireIt(keyes []string, expTime time.Duration) error
- func (client ClusterAndRedisClient) GetClusterInfoAll() (ClusterInfoAll, error)
- func (client ClusterAndRedisClient) GetClusterInfoString() (map[string]string, error)
- func (client ClusterAndRedisClient) GetHashValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ...) (map[string]interface{}, int, string, int, int, error)
- func (client ClusterAndRedisClient) GetKeyTTL(key string, timeFmt string) (string, error)
- func (client ClusterAndRedisClient) GetKeyType(key string) (string, error)
- func (client ClusterAndRedisClient) GetKeyValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ...) (RedisKey, error)
- func (client ClusterAndRedisClient) GetLatestSlave(slaves []SlaveInfo) (SlaveInfo, error)
- func (client ClusterAndRedisClient) GetListLen(key string) (int64, error)
- func (client ClusterAndRedisClient) GetListValue(key string, length int64, eachCnt int64, elementBatch int, ...) ([]string, int, string, int, error)
- func (client ClusterAndRedisClient) GetRedisConfVars(ifErrBreak bool) (RedisConfVar, error)
- func (client ClusterAndRedisClient) GetRedisInfo(section string) (map[string]string, error)
- func (client ClusterAndRedisClient) GetRedisInfoAll(selfIps []string, port int, ifGetSlaveLag bool) (RedisInfoAll, error)
- func (client ClusterAndRedisClient) GetRedisInfoRole() (RedisRoleInfo, error)
- func (client ClusterAndRedisClient) GetRedisOneVarInt64(name string) (int64, error)
- func (client ClusterAndRedisClient) GetRedisOneVarString(name string) (string, error)
- func (client ClusterAndRedisClient) GetRedisOneVarUint64(name string) (uint64, error)
- func (client ClusterAndRedisClient) GetSetValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ...) ([]string, int, string, int, int, error)
- func (client ClusterAndRedisClient) GetSlaveReplInfo(infoStr string) (SlaveInfo, error)
- func (client ClusterAndRedisClient) GetSlavesReplicationStatus(slaveIps map[string]int) (int64, int64, error)
- func (client ClusterAndRedisClient) GetStringValue(key string, ifBytes bool) (string, int, error)
- func (client ClusterAndRedisClient) GetZsetValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ...) (map[string]float64, int, string, int, int, error)
- func (client ClusterAndRedisClient) RedisPing() bool
- type ClusterAndRedisConf
- type ClusterInfoAll
- type ClusterNodeInfo
- type ConfCluster
- type ConfCommon
- type ConfRedis
- type RedisAddr
- type RedisConfVar
- type RedisInfoAll
- type RedisKey
- type RedisRoleInfo
- type SlaveInfo
- type SlotRehash
Constants ¶
This section is empty.
Variables ¶
var ( G_Redis_BigKey_Format_Data string = "%-2d, %-10d, %-10d, %-6s, %-19s, %-10d, %-20s, %-20s\n" G_Redis_BigKey_Format_Header string = "%-2s, %-10s, %-10s, %-6s, %-19s, %-10s, %-20s, %-20s\n" G_Redis_BigKey_Headers []string = []string{"db", "sizeInByte", "elementCnt", "type", "expire", "bigSize", "key", "big"} G_regexp_info_keyspace_db *regexp.Regexp = regexp.MustCompile(`db\d+`) G_regexp_info_replication_slave *regexp.Regexp = regexp.MustCompile(`slave\d+`) )
Functions ¶
func GetAllMastersAddr ¶
func GetAllMastersAddr(sarr map[string]*ClusterNodeInfo) []string
func GetAllSlavesAddr ¶
func GetAllSlavesAddr(sarr map[string]*ClusterNodeInfo) []string
func GetClusterNodesInfo ¶
func GetClusterNodesInfo(client *redis.ClusterClient) (map[string]*ClusterNodeInfo, error)
name addr flags role ping_sent ping_recv config_epoch link_status slots 37328e760f7c5ca1f0430cd59bb6fcae7099e3aa 10.199.203.210:6681 myself,master - 0 0 7 connected 2731-5460 06934f9263df8e6292d2accecef2a6cabc5193a8 10.199.203.210:6683 slave 9fd094136d8ae049dcf8f8e4ff833015ce9186a9 0 1512612681090 13 connected 2725ea3036cd2948d45d82fb8b192b91805b1fbb 10.201.42.179:8209 myself,master - 0 0 1 connected 6823-8191 [6823->-b73527c7435d8b104709dd644c39b0e06ffce96b] b73527c7435d8b104709dd644c39b0e06ffce96b 10.201.41.189:8219 myself,master - 0 0 30 connected [6823-<-2725ea3036cd2948d45d82fb8b192b91805b1fbb]
key = host:port
func GetLatestSlaveOfMasters ¶
func GetRedisAddr ¶
func GetRedisBigkeyHeader ¶
func GetRedisBigkeyHeader() string
func ParseInfoClient ¶
func ParseInfoClient(result map[string]string, info *RedisInfoAll)
func ParseInfoKeyspace ¶
func ParseInfoKeyspace(result map[string]string, info *RedisInfoAll)
func ParseInfoMemory ¶
func ParseInfoMemory(result map[string]string, info *RedisInfoAll)
func ParseInfoPersistent ¶
func ParseInfoPersistent(result map[string]string, info *RedisInfoAll)
func ParseInfoReplication ¶
func ParseInfoReplication(result map[string]string, info *RedisInfoAll)
func ParseInfoSever ¶
func ParseInfoSever(result map[string]string, info *RedisInfoAll)
func ParseInfoStats ¶
func ParseInfoStats(result map[string]string, info *RedisInfoAll)
Types ¶
type ClusterAndRedisClient ¶
type ClusterAndRedisClient struct { Redis *redis.Client Cluster *redis.ClusterClient IsCluster bool }
func GetClusterOrRedisClient ¶
func GetClusterOrRedisClient(cfg ConfCommon, addrs []string, readOnly bool, db int, isCluster bool) (ClusterAndRedisClient, error)
func (ClusterAndRedisClient) CheckIfCluster ¶
func (client ClusterAndRedisClient) CheckIfCluster() (bool, error)
func (ClusterAndRedisClient) DeleteKeyList ¶
func (ClusterAndRedisClient) DeleteKeyString ¶
func (client ClusterAndRedisClient) DeleteKeyString(key string) error
func (ClusterAndRedisClient) DeleteKeysByDirectlyDelIt ¶
func (client ClusterAndRedisClient) DeleteKeysByDirectlyDelIt(keyes []string) error
func (ClusterAndRedisClient) DeleteKeysByExpireIt ¶
func (client ClusterAndRedisClient) DeleteKeysByExpireIt(keyes []string, expTime time.Duration) error
delete key by setting expire time of key to little seconds.
func (ClusterAndRedisClient) GetClusterInfoAll ¶
func (client ClusterAndRedisClient) GetClusterInfoAll() (ClusterInfoAll, error)
func (ClusterAndRedisClient) GetClusterInfoString ¶
func (client ClusterAndRedisClient) GetClusterInfoString() (map[string]string, error)
func (ClusterAndRedisClient) GetHashValue ¶
func (ClusterAndRedisClient) GetKeyTTL ¶
func (client ClusterAndRedisClient) GetKeyTTL(key string, timeFmt string) (string, error)
func (ClusterAndRedisClient) GetKeyType ¶
func (client ClusterAndRedisClient) GetKeyType(key string) (string, error)
func (ClusterAndRedisClient) GetKeyValue ¶
func (client ClusterAndRedisClient) GetKeyValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ifSleep bool, ifCountMem bool, ifNeedValue bool) (RedisKey, error)
get one key info and value
func (ClusterAndRedisClient) GetLatestSlave ¶
func (client ClusterAndRedisClient) GetLatestSlave(slaves []SlaveInfo) (SlaveInfo, error)
func (ClusterAndRedisClient) GetListLen ¶
func (client ClusterAndRedisClient) GetListLen(key string) (int64, error)
func (ClusterAndRedisClient) GetListValue ¶
func (client ClusterAndRedisClient) GetListValue(key string, length int64, eachCnt int64, elementBatch int, elementInterval time.Duration, ifSleep bool, ifBytes bool) ([]string, int, string, int, error)
param: key name, key length, count of elements to get each time, sleep after this process elementBatch element, esleep time for elementInterval in microsecond, if sleep, if calculate memory used in bytes return: value, bytes of the key, biggest element, bytes of the biggest element, error
func (ClusterAndRedisClient) GetRedisConfVars ¶
func (client ClusterAndRedisClient) GetRedisConfVars(ifErrBreak bool) (RedisConfVar, error)
func (ClusterAndRedisClient) GetRedisInfo ¶
func (client ClusterAndRedisClient) GetRedisInfo(section string) (map[string]string, error)
func (ClusterAndRedisClient) GetRedisInfoAll ¶
func (client ClusterAndRedisClient) GetRedisInfoAll(selfIps []string, port int, ifGetSlaveLag bool) (RedisInfoAll, error)
func (ClusterAndRedisClient) GetRedisInfoRole ¶
func (client ClusterAndRedisClient) GetRedisInfoRole() (RedisRoleInfo, error)
func (ClusterAndRedisClient) GetRedisOneVarInt64 ¶
func (client ClusterAndRedisClient) GetRedisOneVarInt64(name string) (int64, error)
func (ClusterAndRedisClient) GetRedisOneVarString ¶
func (client ClusterAndRedisClient) GetRedisOneVarString(name string) (string, error)
func (ClusterAndRedisClient) GetRedisOneVarUint64 ¶
func (client ClusterAndRedisClient) GetRedisOneVarUint64(name string) (uint64, error)
func (ClusterAndRedisClient) GetSetValue ¶
func (client ClusterAndRedisClient) GetSetValue(key string, eachCnt int64, elementBatch int, elementInterval time.Duration, ifSleep bool, ifBytes bool) ([]string, int, string, int, int, error)
param: key name, count of elements to get each time, sleep after processing elementBatch elements,
sleep for elementInterval in microsecond, if calculate memory used in bytes
return: value, bytes of the key, biggest element, bytes of the biggest element, error
func (ClusterAndRedisClient) GetSlaveReplInfo ¶
func (client ClusterAndRedisClient) GetSlaveReplInfo(infoStr string) (SlaveInfo, error)
func (ClusterAndRedisClient) GetSlavesReplicationStatus ¶
func (ClusterAndRedisClient) GetStringValue ¶
func (ClusterAndRedisClient) GetZsetValue ¶
func (ClusterAndRedisClient) RedisPing ¶
func (client ClusterAndRedisClient) RedisPing() bool
type ClusterAndRedisConf ¶
type ClusterAndRedisConf struct { Redis *redis.Options Cluster *redis.ClusterOptions IsCluster bool }
type ClusterInfoAll ¶
type ClusterNodeInfo ¶
type ConfCluster ¶
type ConfCluster struct { ConfCommon Addrs []string // host:port ReadOnly bool // if read slave MaxRedirects int }
func (ConfCluster) CreateNewClientCluster ¶
func (this ConfCluster) CreateNewClientCluster() (*redis.ClusterClient, error)
type ConfCommon ¶
type ConfRedis ¶
type ConfRedis struct { ConfCommon //Network string // tcp|unix Addr string //host:port | socket Database int // db number }
type RedisConfVar ¶
type RedisInfoAll ¶
type RedisInfoAll struct { Redis_version string IsCluster int64 // cluster:1, redis:0 Process_id uint64 Total_connections_received uint64 Connected_clients uint64 Rejected_connections uint64 Blocked_clients uint64 Client_longest_output_list uint64 Client_biggest_input_buf uint64 Total_commands_processed uint64 Instantaneous_ops_per_sec float64 Keyspace_hits uint64 Keyspace_misses uint64 Expired_keys uint64 Evicted_keys uint64 Keys_alldb uint64 // number of keys of all db Keys_expires uint64 // number of keys with expiration of all db Total_net_input_bytes uint64 Total_net_output_bytes uint64 Instantaneous_input_kbps float64 Instantaneous_output_kbps float64 Used_memory uint64 Used_memory_rss uint64 Used_memory_peak uint64 Used_memory_lua uint64 Mem_fragmentation_ratio float64 LoadingRdb int64 Rdb_bgsave_in_progress int64 Rdb_last_bgsave_status int64 // ok: 0, error: 1 Aof_rewrite_in_progress int64 Aof_last_bgrewrite_status int64 // ok: 0, error: 1 Aof_last_write_status int64 // ok: 0, error: 1 Pubsub_channels uint64 Pubsub_patterns uint64 Role string Connected_slaves uint64 Master_host string Master_port uint64 Master_link_status int64 // up: 1, else: 0 SlaveLag int64 Master_sync_in_progress int64 }
type RedisKey ¶
type RedisKey struct { Database uint Bytes int // bytes of key and value ElementCnt int // for list|set|hash|zset, the count of the elements Type string Expire string MaxElementBytes int // bytes of max element of key Key string // key MaxElement string // max element of key Value interface{} }
func (RedisKey) DumpJsonStr ¶
func (RedisKey) GetRedisKeyPrintLine ¶
func (RedisKey) ToStringWithoutValue ¶
type RedisRoleInfo ¶
type SlotRehash ¶
type SlotRehash struct { Slot int SrcId string SrcAddr string DestId string DestAddr string IsMigrate bool // true: migrate, false: importing }
func SlotsStrToSeperateInts ¶
func SlotsStrToSeperateInts(slts []string) ([]int, []SlotRehash)