123456789101112131415161718192021222324 |
- package cache
- import (
- "context"
- "github.com/redis/go-redis/v9"
- "server/global"
- )
- var Redis *redis.Client
- func init() {
- Redis = global.GVA_REDIS
- }
- // 存储离线用户的消息
- func StoreMessages(id, msg string) error {
- return Redis.LPush(context.Background(), "offline:"+id, msg).Err()
- }
- // 获取用户的离线信息
- func GetStoreMessages(id string) []string {
- result, _ := Redis.LRange(context.Background(), "offline:"+id, 0, -1).Result()
- return result
- }
|