-
Notifications
You must be signed in to change notification settings - Fork 972
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 maxEntries
is positives?
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough
|
||
@Override | ||
protected boolean removeEldestEntry(final Map.Entry<String, HttpCacheEntry> eldest) { | ||
if (evictionCallback != null && size() > maxEntries) { |
There was a problem hiding this comment.
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
Added internal cache storage implementation that can be used to implement custom cache storage backends with specific cache entry eviction strategy.
@arturobernalg Please review.