docs: 添加部分注释
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,7 @@ backend/.run/
|
||||
data/
|
||||
.sisyphus/
|
||||
docs/
|
||||
CLAUDE.md
|
||||
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
@@ -34,3 +35,4 @@ go.work.sum
|
||||
# Editor/IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
.claude
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
基于 Go + Vue 3 的短视频 Feed 系统,含账号、视频、点赞、评论、关注、Feed 流、私信、通知,支持 Redis 缓存、RabbitMQ 异步 Worker、分片上传、SSE 实时推送、Docker Compose 部署。
|
||||
|
||||
## 更完整的视频 Feed 流系统项目
|
||||
|
||||
[LeoninCS/GCFeed](https://github.com/LeoninCS/GCFeed) 是更为全面完整的视频 Feed 流系统项目,覆盖更丰富的业务能力与工程实践。
|
||||
|
||||
## 功能
|
||||
|
||||
| 模块 | 功能 |
|
||||
|
||||
@@ -59,10 +59,10 @@ func DeclareTopic(ch *amqp.Channel, exchange string, queue string, bindingKey st
|
||||
if err := ch.ExchangeDeclare(
|
||||
exchange,
|
||||
"topic",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // 持久化参数
|
||||
false, // autoDelete 是否在未使用时自动删除
|
||||
false, // internal 是否交给其他交换机用而不直接收消息
|
||||
false, // noWait 是否不等待 broker 确认
|
||||
nil,
|
||||
); err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
redis "github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// ZincrBy 将有序集合 key 中 member 的分数增加 score。
|
||||
// 如果 member 不存在,则将其添加并设置初始分数为 score。
|
||||
func (c *Client) ZincrBy(ctx context.Context, key string, member string, score float64) error {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil
|
||||
@@ -15,6 +17,7 @@ func (c *Client) ZincrBy(ctx context.Context, key string, member string, score f
|
||||
return c.rdb.ZIncrBy(ctx, key, score, member).Err()
|
||||
}
|
||||
|
||||
// ZAdd 向有序集合 key 中添加一个或多个带分数的成员。
|
||||
func (c *Client) ZAdd(ctx context.Context, key string, members ...redis.Z) error {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil
|
||||
@@ -22,6 +25,7 @@ func (c *Client) ZAdd(ctx context.Context, key string, members ...redis.Z) error
|
||||
return c.rdb.ZAdd(ctx, key, members...).Err()
|
||||
}
|
||||
|
||||
// ZRemRangeByRank 移除有序集合 key 中排名在 [start, stop] 范围内的所有成员。
|
||||
func (c *Client) ZRemRangeByRank(ctx context.Context, key string, start int64, stop int64) error {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil
|
||||
@@ -29,6 +33,7 @@ func (c *Client) ZRemRangeByRank(ctx context.Context, key string, start int64, s
|
||||
return c.rdb.ZRemRangeByRank(ctx, key, start, stop).Err()
|
||||
}
|
||||
|
||||
// ZRangeWithScores 返回有序集合 key 中排名在指定范围内的成员及其分数。
|
||||
func (c *Client) ZRangeWithScores(ctx context.Context, key string, start int64, stop int64) ([]redis.Z, error) {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil, errors.New("redis client not initialized")
|
||||
@@ -36,6 +41,7 @@ func (c *Client) ZRangeWithScores(ctx context.Context, key string, start int64,
|
||||
return c.rdb.ZRangeWithScores(ctx, key, start, stop).Result()
|
||||
}
|
||||
|
||||
// Expire 为 key 设置过期时间,TTL 过后 key 会被自动删除。
|
||||
func (c *Client) Expire(ctx context.Context, key string, ttl time.Duration) error {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil
|
||||
@@ -43,6 +49,8 @@ func (c *Client) Expire(ctx context.Context, key string, ttl time.Duration) erro
|
||||
return c.rdb.Expire(ctx, key, ttl).Err()
|
||||
}
|
||||
|
||||
// ZUnionStore 计算 keys 指定的多个有序集合的并集,将结果存入 dst。
|
||||
// aggregate 控制分数聚合方式,可选 "SUM"、"MIN" 或 "MAX"。
|
||||
func (c *Client) ZUnionStore(ctx context.Context, dst string, keys []string, aggregate string) error {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil
|
||||
@@ -53,6 +61,7 @@ func (c *Client) ZUnionStore(ctx context.Context, dst string, keys []string, agg
|
||||
}).Err()
|
||||
}
|
||||
|
||||
// Exists 判断 key 是否存在于 Redis 中。
|
||||
func (c *Client) Exists(ctx context.Context, key string) (bool, error) {
|
||||
if c == nil || c.rdb == nil {
|
||||
return false, nil
|
||||
@@ -61,6 +70,7 @@ func (c *Client) Exists(ctx context.Context, key string) (bool, error) {
|
||||
return n > 0, err
|
||||
}
|
||||
|
||||
// ZRevRange 返回有序集合 key 中排名在 [start, stop] 范围内的成员,按分数从高到低排序。
|
||||
func (c *Client) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error) {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil, nil
|
||||
@@ -68,6 +78,8 @@ func (c *Client) ZRevRange(ctx context.Context, key string, start, stop int64) (
|
||||
return c.rdb.ZRevRange(ctx, key, start, stop).Result()
|
||||
}
|
||||
|
||||
// ZRevRangeByScore 返回有序集合 key 中分数在 [min, max] 范围内的成员,按分数从高到低排序。
|
||||
// offset 和 count 用于分页控制。
|
||||
func (c *Client) ZRevRangeByScore(ctx context.Context, key string, max, min string, offset, count int64) ([]string, error) {
|
||||
if c == nil || c.rdb == nil {
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user