Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a caching implementation for InstallationsService #268

Merged
merged 4 commits into from
Jun 29, 2023

Conversation

nvelat
Copy link
Contributor

@nvelat nvelat commented Jun 26, 2023

When querying repository info many times in succession, it is useful to cache results about the app installation in order to reduce API requests to github. This PR adds a CachingInstallationsService which uses a TTL based cache to store results about app installation info with regards to repositories or owners.

@nvelat nvelat requested a review from bluekeyes June 26, 2023 16:36
Copy link
Member

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

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

Code looks good and I think this makes sense to add here. As I mentioned in Slack, it's probably worth considering a time-based cache instead of an LRU cache, since that should fix the "wrong ID" problem in practice. I usually use patrickm/go-cache for situations like this, but there might be other libraries worth trying.

githubapp/installations_caching.go Outdated Show resolved Hide resolved
@nvelat
Copy link
Contributor Author

nvelat commented Jun 29, 2023

Good suggestion! Switched to a time based cache implementation

@nvelat nvelat requested a review from a team June 29, 2023 13:36
@nvelat nvelat merged commit 3be3441 into develop Jun 29, 2023
5 checks passed
@nvelat nvelat deleted the nv/caching-installs branch June 29, 2023 15:18
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.

None yet

2 participants