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

Make size report in bytes instead of number of entries when weighted. #14

Merged
merged 1 commit into from
Apr 13, 2016

Conversation

drcrallen
Copy link
Contributor

Currently size is simply reported in number of entries, this makes the size report as the weight size, if a maximum size is specified.

size = eviction.weightedSize().orElse(-1);
} else {
size = -1;
}
Copy link

Choose a reason for hiding this comment

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

it's a bit weird to convert to optional to null to check if they're present. why not just check isPresent directly?

Alternatively you could go full functional and embrace the option style (although OptionalLong throws a bit of a wrench in here, because it's not Optional, in which case we could have used flatMap)

cache
      .policy()
      .eviction()
      .map(eviction -> eviction.isWeighted() ? eviction.weightedSize() : OptionalLong.empty())
      .orElse(OptionalLong.empty()).orElse(-1);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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

Successfully merging this pull request may close these issues.

None yet

2 participants