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

@@ -21,16 +21,15 @@ import (
"errors"
"time"
redisV9 "github.com/redis/go-redis/v9"
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
)
type AppCache struct {
cacheCli *redisV9.Client
cacheCli cache.Cmdable
}
func NewAppCache(cacheCli *redisV9.Client) *AppCache {
func NewAppCache(cacheCli cache.Cmdable) *AppCache {
return &AppCache{
cacheCli: cacheCli,
}
@@ -39,7 +38,7 @@ func NewAppCache(cacheCli *redisV9.Client) *AppCache {
func (a *AppCache) Get(ctx context.Context, key string) (value string, exist bool, err error) {
cmd := a.cacheCli.Get(ctx, key)
if cmd.Err() != nil {
if errors.Is(cmd.Err(), redisV9.Nil) {
if errors.Is(cmd.Err(), cache.Nil) {
return "", false, nil
}
return "", false, cmd.Err()

View File

@@ -25,12 +25,12 @@ import (
"sync"
"time"
redisV9 "github.com/redis/go-redis/v9"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal"
"github.com/coze-dev/coze-studio/backend/domain/app/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/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/logs"
@@ -50,7 +50,7 @@ type appRepoImpl struct {
type APPRepoComponents struct {
IDGen idgen.IDGenerator
DB *gorm.DB
CacheCli *redisV9.Client
CacheCli cache.Cmdable
}
func NewAPPRepo(components *APPRepoComponents) AppRepository {