redis

package
v0.0.0-...-5e3d58f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

实现方法: func AddRelation(userId int64, toUserId int64) 增加关系 func DeleteRelation(userId int64, toUserId int64) 删除关系 func PutFollowList(userId int64, FollowList []int64) 将数据库数据写入到redis中 func PutFollowerList(userId int64, FollowerList []int64) 将数据库文件写入到redis中

Index

Constants

View Source
const (
	Prefix = "douyin:" // 项目key前缀

	KeyUserInfo = "userinfo:" //保存用户信息
	KeyUserId   = "userId:"   //保存用户信息
)

redis key 注意使用命名空间的方式,方便查询和拆分

Variables

View Source
var (
	Nil = redis.Nil
)

Functions

func AddRelation

func AddRelation(ctx context.Context, userId int64, toUserId int64) error

在Redis中添加一个关系

func Close

func Close()

func DeleteRelation

func DeleteRelation(ctx context.Context, userId int64, toUserId int64) error

在Redis中删除一段关系

func GetFollowList

func GetFollowList(ctx context.Context, userId int64) ([]int64, error)

func GetFollowerList

func GetFollowerList(ctx context.Context, userId int64) ([]int64, error)

func GetFriendList

func GetFriendList(ctx context.Context, userId int64) ([]int64, error)

func GetIsFollow

func GetIsFollow(ctx context.Context, userId int64, toUserId int64) (bool, error)

func GetRedisKey

func GetRedisKey(servicename, key string) string

给redis key加上前缀

func Init

func Init() (err error)

Init 初始化连接

func IsFollowKeyExist

func IsFollowKeyExist(ctx context.Context, userId int64) (bool, error)

检查给定的 userId 的关注列表是否存在

func IsFollowerKeyExist

func IsFollowerKeyExist(ctx context.Context, userId int64) (bool, error)

检查给定的 userId 的粉丝列表是否存在

func PutFollowList

func PutFollowList(ctx context.Context, userId int64, FollowIdList []int64) error

把FollowList 关注用户列表数据写回redis

func PutFollowerList

func PutFollowerList(ctx context.Context, userId int64, FollowerIdList []int64) error

把FollowerList 粉丝列表数据写回redis

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL