Files
2021-09-28 11:47:19 +08:00

57 lines
1.1 KiB
Go

package event
import (
"SciencesServer/serve/cache"
"fmt"
)
type (
RedisHashProduce struct{}
RedisHashDestroy struct{}
)
type (
RedisListProduce struct{}
RedisListDestroy struct{}
)
func (this *RedisHashProduce) Handle(args ...interface{}) {
_ = cache.Cache.HSet(args[0].(string), args[1].(string), args[2])
}
func NewRedisHashProduce() *RedisHashProduce {
return &RedisHashProduce{}
}
func (this *RedisHashDestroy) Handle(args ...interface{}) {
fields := make([]string, 0)
for i := 1; i < len(args); i++ {
fields = append(fields, args[i].(string))
}
_ = cache.Cache.HDel(args[0].(string), fields...)
}
func NewRedisHashDestroy() *RedisHashDestroy {
return &RedisHashDestroy{}
}
func (this *RedisListProduce) Handle(args ...interface{}) {
_ = cache.Cache.SAdd(args[0].(string), args[1:]...)
}
func NewRedisListProduce() *RedisListProduce {
return &RedisListProduce{}
}
func (this *RedisListDestroy) Handle(args ...interface{}) {
err := cache.Cache.SRem(args[0].(string), args[1:]...)
fmt.Println(err)
}
func NewRedisListDestroy() *RedisListDestroy {
return &RedisListDestroy{}
}