feat: update the redis reference to cache.Cmdable instead (#535)

This commit is contained in:
Ryo
2025-08-04 17:36:18 +08:00
committed by GitHub
parent c7bf6bbdec
commit adc5986d13
23 changed files with 74 additions and 78 deletions

View File

@@ -22,10 +22,9 @@ import (
"errors"
"fmt"
"github.com/redis/go-redis/v9"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/developer_api"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
@@ -53,7 +52,7 @@ func (sa *SingleAgentDraftDAO) UpdateDisplayInfo(ctx context.Context, userID int
func (sa *SingleAgentDraftDAO) GetDisplayInfo(ctx context.Context, userID, agentID int64) (*entity.AgentDraftDisplayInfo, error) {
key := makeAgentDisplayInfoKey(userID, agentID)
data, err := sa.cacheClient.Get(ctx, key).Result()
if errors.Is(err, redis.Nil) {
if errors.Is(err, cache.Nil) {
tabStatusDefault := developer_api.TabStatus_Default
return &entity.AgentDraftDisplayInfo{
AgentID: agentID,

View File

@@ -20,24 +20,23 @@ import (
"context"
"strconv"
"github.com/redis/go-redis/v9"
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
)
func NewCountRepo(cli *redis.Client) *CounterImpl {
func NewCountRepo(cli cache.Cmdable) *CounterImpl {
return &CounterImpl{
cacheClient: cli,
}
}
type CounterImpl struct {
cacheClient *redis.Client
cacheClient cache.Cmdable
}
func (c *CounterImpl) Get(ctx context.Context, key string) (int64, error) {
val, err := c.cacheClient.Get(ctx, key).Result()
if err == redis.Nil {
if err == cache.Nil {
return 0, nil
}
if err != nil {

View File

@@ -20,13 +20,13 @@ import (
"context"
"errors"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/model"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/query"
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/types/errno"
@@ -35,10 +35,10 @@ import (
type SingleAgentDraftDAO struct {
idGen idgen.IDGenerator
dbQuery *query.Query
cacheClient *redis.Client
cacheClient cache.Cmdable
}
func NewSingleAgentDraftDAO(db *gorm.DB, idGen idgen.IDGenerator, cli *redis.Client) *SingleAgentDraftDAO {
func NewSingleAgentDraftDAO(db *gorm.DB, idGen idgen.IDGenerator, cli cache.Cmdable) *SingleAgentDraftDAO {
query.SetDefault(db)
return &SingleAgentDraftDAO{