This commit is contained in:
henry
2021-11-02 09:43:19 +08:00
parent 570bb3c772
commit 4734344985
78 changed files with 4798 additions and 0 deletions

56
app/event/redis.go Normal file
View File

@ -0,0 +1,56 @@
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{}
}