A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
refactor(dashboard): rename dashboard cache key
LinkinStarsa48c53d6c632
diff --git a/internal/schema/dashboard_schema.go b/internal/schema/dashboard_schema.goindex 88afed90..844023d4 100644--- a/internal/schema/dashboard_schema.go+++ b/internal/schema/dashboard_schema.go@@ -5,8 +5,8 @@ import "time"var AppStartTime time.Timeconst (- DashBoardCachekey = "answer@dashboard"- DashBoardCacheTime = 60 * time.Minute+ DashboardCacheKey = "answer:dashboard"+ DashboardCacheTime = 60 * time.Minute)type DashboardInfo struct {diff --git a/internal/service/dashboard/dashboard_service.go b/internal/service/dashboard/dashboard_service.goindex f62ce60f..e6b26701 100644--- a/internal/service/dashboard/dashboard_service.go+++ b/internal/service/dashboard/dashboard_service.go@@ -96,7 +96,7 @@ func (ds *dashboardService) Statistical(ctx context.Context) (*schema.DashboardI}func (ds *dashboardService) getFromCache(ctx context.Context) (*schema.DashboardInfo, error) {- infoStr, err := ds.data.Cache.GetString(ctx, schema.DashBoardCachekey)+ infoStr, err := ds.data.Cache.GetString(ctx, schema.DashboardCacheKey)if err != nil {return nil, err}@@ -109,7 +109,7 @@ func (ds *dashboardService) getFromCache(ctx context.Context) (*schema.Dashboardfunc (ds *dashboardService) setCache(ctx context.Context, info *schema.DashboardInfo) {infoStr, _ := json.Marshal(info)- err := ds.data.Cache.SetString(ctx, schema.DashBoardCachekey, string(infoStr), schema.DashBoardCacheTime)+ err := ds.data.Cache.SetString(ctx, schema.DashboardCacheKey, string(infoStr), schema.DashboardCacheTime)if err != nil {log.Errorf("set dashboard statistical failed: %s", err)}diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.goindex a3ba10c4..03d94752 100644--- a/internal/service/question_common/question.go+++ b/internal/service/question_common/question.go@@ -596,7 +596,7 @@ func (qs *QuestionCommon) SetCache(ctx context.Context, cachekey string, info inreturn errors.InternalServer(reason.UnknownError).WithError(err).WithStack()}- err = qs.data.Cache.SetString(ctx, cachekey, string(infoStr), schema.DashBoardCacheTime)+ err = qs.data.Cache.SetString(ctx, cachekey, string(infoStr), schema.DashboardCacheTime)if err != nil {return errors.InternalServer(reason.UnknownError).WithError(err).WithStack()}