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

HTTPCLIENT-2284: internal cache storage improvements #478

Merged
merged 1 commit into from
Aug 27, 2023

Conversation

ok2c
Copy link
Member

@ok2c ok2c commented Aug 26, 2023

Added internal cache storage implementation that can be used to implement custom cache storage backends with specific cache entry eviction strategy.

@arturobernalg Please review.

Copy link
Member

@arturobernalg arturobernalg left a comment

Choose a reason for hiding this comment

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

@ok2c the change-set looks good. I just add a small question.

private final Queue<HttpCacheStorageEntry> evictionQueue;
private final Consumer<HttpCacheStorageEntry> evictionCallback;

public InternalCacheStorage(final int maxEntries, final Consumer<HttpCacheStorageEntry> evictionCallback) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we check if maxEntriesis positives?

Copy link
Member Author

Choose a reason for hiding this comment

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

@arturobernalg I would say not. Not at this level. Input validation should be done at the public API level,

Copy link
Member

Choose a reason for hiding this comment

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

fair enough

@arturobernalg arturobernalg merged commit 39e2ff2 into apache:5.4.x Aug 27, 2023
7 checks passed

@Override
protected boolean removeEldestEntry(final Map.Entry<String, HttpCacheEntry> eldest) {
if (evictionCallback != null && size() > maxEntries) {

Choose a reason for hiding this comment

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

This is a change in behaviour, now the maxEntries size limit is no longer honoured by default

@ok2c ok2c deleted the HTTPCLIENT-2284 branch September 17, 2023 12:43
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.

3 participants