You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
981 B
37 lines
981 B
1 month ago
|
package common_utils
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"gitea.anxinyun.cn/container/common_utils/configLoad"
|
||
|
)
|
||
|
|
||
|
type AlarmCacheUtil struct {
|
||
|
AlarmCachePerfix string
|
||
|
|
||
|
ALARM_SOURCE_DEVICE int
|
||
|
ALARM_SOURCE_STATION int
|
||
|
redisHelper *RedisHelper
|
||
|
}
|
||
|
|
||
|
func NewAlarmCacheUtil() *AlarmCacheUtil {
|
||
|
redisAddr := configLoad.LoadConfig().GetString("redis.address")
|
||
|
return &AlarmCacheUtil{
|
||
|
AlarmCachePerfix: "alarm",
|
||
|
ALARM_SOURCE_DEVICE: 1,
|
||
|
ALARM_SOURCE_STATION: 2,
|
||
|
redisHelper: NewRedisHelper("", redisAddr),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (the *AlarmCacheUtil) Rem(sourceType int, sourceId string, alarmTypes ...string) int64 {
|
||
|
//redisHelper{}.Get()
|
||
|
return 0
|
||
|
}
|
||
|
func (the *AlarmCacheUtil) Add(sourceType int, sourceId string, alarmTypes ...string) int64 {
|
||
|
n := the.redisHelper.SAdd(the.key(sourceType, sourceId), alarmTypes...)
|
||
|
return n
|
||
|
}
|
||
|
func (the *AlarmCacheUtil) key(sourceType int, sourceId string) string {
|
||
|
return fmt.Sprintf("%s:%d:%s", the.AlarmCachePerfix, sourceType, sourceId)
|
||
|
}
|