Files
ArmedPolice/app/event/redis.go

57 lines
1.1 KiB
Go
Raw Normal View History

2021-11-02 09:43:19 +08:00
package event
import (
"ArmedPolice/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{}
}