Skip to content

add cache#86

Draft
adrian-brady wants to merge 8 commits intomainfrom
cache
Draft

add cache#86
adrian-brady wants to merge 8 commits intomainfrom
cache

Conversation

@adrian-brady
Copy link
Contributor

Adds a cache. It is not finished yet - it currently breaks filters

return false
return result, false
default:
select {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enqueue: adds job to channel. queue map: keys are same as cache (queries). value is slice of result channels.

return suggestions, nil
}

func (c *kendraClientImpl) MakeQuery(ctx context.Context, query string, filters map[string][]string, pageNum int) (KendraResults, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encode filters

c.mu.Lock()
defer c.mu.Unlock()

expiration := time.Now().Add(duration).Unix()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max size?

c.log.DebugContext(ctx, "Kendra query executed successfully", "result_count", queueResult.Value.Count)

results := queryResult.Results
results := queueResult.Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get all results

res = result
}

pageNum := 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not include page numbers in the cache and query for all 100 results and then just return 10 results for page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants