Enhance tender recommendation service with improved caching and pagination
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Introduced a context with a timeout for Redis cache retrieval in the `getCachedAIRecommendations` method, ensuring more robust handling of potential delays. - Added a new file `recommendation_page.go` to encapsulate the logic for building recommendation pages, improving code organization and readability. - Implemented a `buildRecommendationPage` method to handle pagination and batch processing of recommendations, enhancing performance and user experience. - Created a new test file `recommendation_page_test.go` to validate the functionality of the recommendation page building process, ensuring correct pagination and batch resolution. This update significantly improves the efficiency and maintainability of the tender recommendation service by optimizing caching and implementing structured pagination handling.
This commit is contained in:
@@ -407,7 +407,10 @@ func (s *companyService) getCachedAIRecommendations(ctx context.Context, company
|
||||
return nil, false
|
||||
}
|
||||
|
||||
raw, err := s.redisClient.Get(ctx, aiRecommendationCacheKey(companyID))
|
||||
readCtx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
raw, err := s.redisClient.Get(readCtx, aiRecommendationCacheKey(companyID))
|
||||
if err != nil {
|
||||
if err != redis.Nil {
|
||||
s.logger.Warn("Failed to read AI recommendation cache", map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user