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) }