init
This commit is contained in:
56
app/event/redis.go
Normal file
56
app/event/redis.go
Normal 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{}
|
||||
}
|
Reference in New Issue
Block a user