Browse Source

update 窗口创建原因

dev v0.0.12
lucas 3 months ago
parent
commit
34c2cb5d28
  1. 28
      cacheData.go

28
cacheData.go

@ -27,13 +27,14 @@ type expirationInfo struct {
// CacheWindow
// 存储大量测点缓存数据
type CacheWindow struct {
Id string
windowLen int //窗体长度
WindowSize int //窗体大小
MethodId int //滑窗方法
LatestData any
ring *ring.Ring
Params FilterParams
Id string
windowLen int //窗体长度
WindowSize int //窗体大小
MethodId int //滑窗方法
CreatReason string //创建原因
LatestData any
ring *ring.Ring
Params FilterParams
//过期控制
Expire expirationInfo
}
@ -74,17 +75,18 @@ func (c *CacheWindow) MarshalBinary() (data []byte, err error) {
func (c *CacheWindow) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, c)
}
func NewCacheWindow(id string, size, methodId int, params FilterParams) CacheWindow {
func NewCacheWindow(id string, size, methodId int, params FilterParams, creatReason string) CacheWindow {
limit := 10
if size > limit {
size = 10
}
return CacheWindow{
Id: id,
WindowSize: size,
MethodId: methodId,
ring: ring.New(size),
Params: params,
Id: id,
WindowSize: size,
MethodId: methodId,
ring: ring.New(size),
Params: params,
CreatReason: creatReason,
Expire: expirationInfo{
UpdateTime: time.Now(),
Duration: 60 * 2,

Loading…
Cancel
Save