Refactor recommendation page cache handling and configuration
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Removed the `RecommendationPageCacheLanguages` configuration from `AISummarizerConfig` to streamline cache management. - Updated the `companyService` and `tenderService` to utilize the new `InvalidateRecommendedTendersPageCache` method for cache invalidation, enhancing clarity and efficiency. - Refactored the `invalidateRecommendedTendersPageCache` method to eliminate unnecessary context parameters, simplifying the function signature. - Improved the handling of page cache refresh logic by consolidating language handling within the `tenderService`, ensuring consistent behavior across services. - Cleaned up related tests and removed deprecated functions to maintain code quality and readability. This update enhances the maintainability of the recommendation caching system by simplifying configuration and improving cache invalidation logic.
This commit is contained in:
@@ -92,7 +92,6 @@ type tenderService struct {
|
||||
aiSummarizerStorage AISummarizerStorage
|
||||
redisClient redis.Client
|
||||
pageCacheTTL time.Duration
|
||||
pageCacheLanguages []string
|
||||
defaultLanguage string
|
||||
}
|
||||
|
||||
@@ -117,7 +116,6 @@ func NewService(
|
||||
aiStorage AISummarizerStorage,
|
||||
redisClient redis.Client,
|
||||
recommendationPageCacheTTL time.Duration,
|
||||
recommendationPageCacheLanguages []string,
|
||||
defaultLanguage string,
|
||||
) Service {
|
||||
if strings.TrimSpace(defaultLanguage) == "" {
|
||||
@@ -134,7 +132,6 @@ func NewService(
|
||||
aiSummarizerStorage: aiStorage,
|
||||
redisClient: redisClient,
|
||||
pageCacheTTL: recommendationPageCacheTTL,
|
||||
pageCacheLanguages: normalizePageCacheLanguages(defaultLanguage, recommendationPageCacheLanguages),
|
||||
defaultLanguage: strings.ToLower(defaultLanguage),
|
||||
}
|
||||
}
|
||||
@@ -999,7 +996,7 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
|
||||
}
|
||||
|
||||
if len(companyIDs) == 0 && companyID != "" {
|
||||
s.ScheduleRefreshRecommendedTendersPageCache(companyID)
|
||||
s.schedulePageCacheRefreshForLanguage(companyID, lang)
|
||||
}
|
||||
|
||||
excluded, excludedByCompany, err := s.loadRecommendationExclusions(ctx, form, companyID, companyIDs)
|
||||
@@ -1030,7 +1027,7 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
paged := s.buildRecommendedTenderListResponses(pageResult.items, lang)
|
||||
paged := s.buildRecommendedTenderResponsesParallel(ctx, pageResult.items, lang)
|
||||
|
||||
return &SearchResponse{
|
||||
Tenders: paged,
|
||||
|
||||
Reference in New Issue
Block a user