Compare commits

...

1 Commits
v0.0.11 ... dev

Author SHA1 Message Date
lucas 34c2cb5d28 update 窗口创建原因 2 weeks ago
  1. 28
      cacheData.go

28
cacheData.go

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

Loading…
Cancel
Save