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

Improve caching mechanism #184

Merged
merged 8 commits into from
Aug 17, 2024
Merged

Conversation

sridamul
Copy link
Contributor

Closes #176

Testing done

interactive tests + unit tests

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@sridamul sridamul requested a review from a team as a code owner August 17, 2024 07:51
* @param cacheKey key to lookup, i.e. update-center
* @return the cached json object as a string or null
*/
public String retrieveFromCache(String cacheKey) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would introduce a simple POJO

Suggested change
public String retrieveFromCache(String cacheKey) {
public CacheItem retrieveFromCache(String cacheKey) {
``

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also a bit more context. If we add a class CacheItem (abstract or not) it means that we can cache entities like Plugin or other content

@@ -30,4 +44,62 @@ void createCache() {
}
}
}

public void addToCache(String cacheKey, String value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public void addToCache(String cacheKey, String value) {
public void addToCache(String cacheKey, CacheItem item) {

private final Path cache;
private final Clock clock;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it a member ? My feeling is that a simple static constant would fit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @jonesbusy Doesn't a member useful for testing purposes?

Copy link
Collaborator

@jonesbusy jonesbusy left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, some minor code changes required

sridamul and others added 3 commits August 17, 2024 14:43
@jonesbusy
Copy link
Collaborator

Let me know if you prefer to merge as is and improve later. Remaining point are not blocking for me

@sridamul
Copy link
Contributor Author

We can merge it

@jonesbusy jonesbusy merged commit d3d517b into jenkins-infra:main Aug 17, 2024
14 checks passed
@sridamul sridamul deleted the improve-caching branch August 17, 2024 17:56
@jonesbusy jonesbusy added the enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update-center.json is never refreshed
3 participants