更改规则链缓存

This commit is contained in:
XM-GO
2023-09-13 17:45:08 +08:00
parent ed8613b6fd
commit 70fb34b90f
11 changed files with 302 additions and 29 deletions

View File

@@ -5,7 +5,6 @@ import (
"pandax/apps/device/services"
"pandax/pkg/events"
"pandax/pkg/global"
"time"
)
// 初始化事件监听
@@ -18,10 +17,7 @@ func InitEvents() {
})
if list != nil {
for _, product := range *list {
err := global.RedisDb.Set(product.Id, codeData, time.Hour*24*365)
if err != nil {
global.Log.Errorf("事件监听执行错误:%s", err.Error())
}
global.Cache.Put(product.Id, codeData)
}
}
})

View File

@@ -92,3 +92,11 @@ func InterfaceToStruct(m interface{}, s interface{}) error {
return nil
}
func StringToStruct(m string, s interface{}) error {
err := json.Unmarshal([]byte(m), s)
if err != nil {
return err
}
return nil
}