redis

package
v0.0.0-...-27cccc6 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package redis provides ...

Package redis provides ...

Package redis provides ...

Package redis provides ...

Index

Constants

View Source
const (
	Prefix                      = "bluebell:"
	KeyPostTimeZSet             = "post:time"         // zset: 贴子及发帖的时间
	KeyPostScoreZSet            = "post:score"        // zset: 贴子及投票的分数
	KeyPostVotedZSetPrefix      = "post:voted:"       // zset: 记录用户以投票类型,参数是 psot id
	KeyUserAccessTokenSetPrefix = "user:accessToken:" // set 记录用户登录时的accessToken
	KeyCommunitySetPrefis       = "community:"        // set:保存每个分区下帖子的id
)

Variables

View Source
var (
	ErrVoteTimeExpire = errors.New("投票时间已过")
	ErrVoteRepeated   = errors.New("不允许重复投票")
)
View Source
var (
	ErrorKeyNotExist = errors.New("token不存在,请登录")
)

Functions

func Close

func Close()

Close 关闭 redis 连接

func CreatePost

func CreatePost(postID, communityID int64) error

CreatePost 初始化帖子分数的redis数据

func GetAToken

func GetAToken(userID string) (redisToken string, err error)

func GetCommunityPostIDsInOrder

func GetCommunityPostIDsInOrder(p *models.ParamPostList) ([]string, error)

GetCommunityPostIDsInOrder 按社区查询ids

func GetPostIDsInOrder

func GetPostIDsInOrder(p *models.ParamPostList) ([]string, error)

GetPostIDsInOrder 获取指定区间的帖子id,并按分数(根据参数决定 分数/时间)从高到低排序

func GetPostVoteData

func GetPostVoteData(ids []string) (data []int64, err error)

GetPostVoteData 根据ids查询每篇帖子的投赞成票的数据 注意当使用for循环发送查询的时候注意使用pipeline减少发送请求的RTT

func Init

func Init(cfg *settings.RedisConfig) (err error)

Init 初始化 redis 连接

func SetAToken

func SetAToken(userID string, aToken string) error

func VoteForPost

func VoteForPost(userID, postID string, value float64) error

VoteForPost

Types

This section is empty.

Jump to

Keyboard shortcuts

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