refactor: remove Gorse integration and implement HotRank feature
- Removed Gorse-related configurations, handlers, and dependencies from the codebase. - Introduced HotRank feature with configuration options for ranking posts based on recent activity. - Updated application structure to support HotRank processing, including new caching mechanisms and database interactions. - Cleaned up related DTOs and repository methods to reflect the removal of Gorse and the addition of HotRank functionality.
This commit is contained in:
23
internal/cache/redis_cache.go
vendored
23
internal/cache/redis_cache.go
vendored
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
redislib "github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
|
||||
redisPkg "carrot_bbs/internal/pkg/redis"
|
||||
@@ -53,7 +53,7 @@ func (c *RedisCache) Get(key string) (interface{}, bool) {
|
||||
key = normalizeKey(key)
|
||||
data, err := c.client.Get(c.ctx, key)
|
||||
if err != nil {
|
||||
if err == redis.Nil {
|
||||
if err == redislib.Nil {
|
||||
return nil, false
|
||||
}
|
||||
zap.L().Error("Failed to get key",
|
||||
@@ -219,6 +219,25 @@ func (c *RedisCache) ZRevRangeByScore(ctx context.Context, key string, max, min
|
||||
return c.client.ZRevRangeByScore(ctx, key, max, min, offset, count)
|
||||
}
|
||||
|
||||
// ZRevRange 按排名倒序获取成员
|
||||
func (c *RedisCache) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error) {
|
||||
key = normalizeKey(key)
|
||||
return c.client.ZRevRange(ctx, key, start, stop)
|
||||
}
|
||||
|
||||
// ZReplaceSortedSet 删除后整表重写 ZSET
|
||||
func (c *RedisCache) ZReplaceSortedSet(ctx context.Context, key string, members []redislib.Z) error {
|
||||
key = normalizeKey(key)
|
||||
rdb := c.client.GetClient()
|
||||
if err := rdb.Del(ctx, key).Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(members) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.client.ZAddArgs(ctx, key, members...)
|
||||
}
|
||||
|
||||
// ZRem 删除 Sorted Set 成员
|
||||
func (c *RedisCache) ZRem(ctx context.Context, key string, members ...interface{}) error {
|
||||
key = normalizeKey(key)
|
||||
|
||||
Reference in New Issue
Block a user