cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CACHE_HISTORY_MAX_LEN          = 5
	GET_CACHE_HISTORY_LEN_INTERVAL = time.Duration(60) * time.Second
)
View Source
const (
	//EXTRACTOR_DEFAULT_SLEEP_TIME       = time.Duration(1000) * time.Millisecond //default is 1000ms
	EXTRACTOR_DEFAULT_HISTORY_INTERVAL = 420 //默认下个时间段map创建超过7分钟,本时间段的数据才可以写入,确保本时间段数据cache完全
)

Variables

View Source
var (
	GaugeCacheHistory   *CacheHistory
	CounterCacheHistory *CacheHistory
	BigMapIndexArray    []string
	AllowMinKey         int64
	ExtractedKey        int64
	CacheHistoryIsFull  bool
)

Functions

func CounterNew

func CounterNew(key int64, pk string, val *model.TrendItem) interface{}

func CounterTrendResult

func CounterTrendResult(item interface{}) *g.TrendResult

func CounterUpdate

func CounterUpdate(item interface{}, val *model.TrendItem)

func GuageNew

func GuageNew(key int64, pk string, val *model.TrendItem) interface{}

func GuageTrendResult

func GuageTrendResult(item interface{}) *g.TrendResult

func GuageUpdate

func GuageUpdate(item interface{}, val *model.TrendItem)

func Push

func Push(items []*model.TrendItem)

func Start

func Start()

Types

type CacheBigMap

type CacheBigMap struct {
	sync.RWMutex
	CreateTime int64
	M          map[string]*ItemMap
}

func NewCacheBigMap

func NewCacheBigMap(newF NewFunction, updateF UpdateFunction, resultF ResultFunction) *CacheBigMap

func (*CacheBigMap) Delete

func (this *CacheBigMap) Delete(key string)

func (*CacheBigMap) Get

func (this *CacheBigMap) Get(key string) (*ItemMap, bool)

func (*CacheBigMap) GetCreateTime

func (this *CacheBigMap) GetCreateTime() int64

type CacheHistory

type CacheHistory struct {
	sync.RWMutex
	M map[int64]*CacheBigMap
}

func NewCacheHistory

func NewCacheHistory() *CacheHistory

func (*CacheHistory) Delete

func (this *CacheHistory) Delete(key int64)

func (*CacheHistory) Get

func (this *CacheHistory) Get(key int64) (*CacheBigMap, bool)

func (*CacheHistory) GetItem

func (this *CacheHistory) GetItem(key int64, pk string) (interface{}, bool)

func (*CacheHistory) Keys

func (this *CacheHistory) Keys() []int64

func (*CacheHistory) Len

func (this *CacheHistory) Len() int

func (*CacheHistory) Set

func (this *CacheHistory) Set(key int64, val *CacheBigMap) *CacheBigMap

type CounterItem

type CounterItem struct {
	sync.RWMutex
	Endpoint  string
	Metric    string
	Tags      string
	DsType    string
	Step      int
	LastValue float64
	LastTime  int64
	Max       float64
	Min       float64
	Sum       float64
	Num       int
}

func (*CounterItem) GetTrendResult

func (this *CounterItem) GetTrendResult() *g.TrendResult

func (*CounterItem) Update

func (this *CounterItem) Update(val *model.TrendItem)

type GaugeItem

type GaugeItem struct {
	sync.RWMutex
	Endpoint string
	Metric   string
	Tags     string
	DsType   string
	Step     int
	Max      float64
	Min      float64
	Sum      float64
	Num      int
}

func (*GaugeItem) GetTrendResult

func (this *GaugeItem) GetTrendResult() *g.TrendResult

func (*GaugeItem) Update

func (this *GaugeItem) Update(val *model.TrendItem)

type ItemMap

type ItemMap struct {
	sync.RWMutex
	NewFunc    NewFunction
	UpdateFunc UpdateFunction
	ResultFunc ResultFunction
	M          map[string]interface{}
}

func NewItemMap

func NewItemMap(newF NewFunction, updateF UpdateFunction, resultF ResultFunction) *ItemMap

func (*ItemMap) BatchDelete

func (this *ItemMap) BatchDelete(keys []string)

func (*ItemMap) Delete

func (this *ItemMap) Delete(key string)

func (*ItemMap) DeleteAll

func (this *ItemMap) DeleteAll()

func (*ItemMap) Flush

func (this *ItemMap) Flush(key int64)

func (*ItemMap) Get

func (this *ItemMap) Get(key string) (interface{}, bool)

func (*ItemMap) Len

func (this *ItemMap) Len() int

func (*ItemMap) Set

func (this *ItemMap) Set(key string, val interface{})

func (*ItemMap) Update

func (this *ItemMap) Update(key int64, pk string, val *model.TrendItem)

type NewFunction

type NewFunction func(key int64, pk string, val *model.TrendItem) interface{}

type ResultFunction

type ResultFunction func(item interface{}) *g.TrendResult

type UpdateFunction

type UpdateFunction func(item interface{}, val *model.TrendItem)

Jump to

Keyboard shortcuts

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