Skip to content

Add Guava Cache to CitationStyleCache#3089

Merged
LinusDietz merged 1 commit into
JabRef:masterfrom
snisnisniksonah:guava_cache
Aug 10, 2017
Merged

Add Guava Cache to CitationStyleCache#3089
LinusDietz merged 1 commit into
JabRef:masterfrom
snisnisniksonah:guava_cache

Conversation

@snisnisniksonah

Copy link
Copy Markdown
Contributor

This uses Guava's Cache instead of a HashMap for caching.

This enables us to limit the number of cached entries. The current number 1024 is chosen arbitrarily. Maybe, 100 could be enough.

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested manually in GUI. LGTM.

this.citationStyle = citationStyle;
citationStyleCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build(new CacheLoader<BibEntry, String>() {
@Override
public String load(BibEntry entry) throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be converted to a Lambda expression?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

According to https://stackoverflow.com/a/34424577/873282, this is not possible. The basic class has more than one abstract method (see https://github.com/google/guava/blob/master/guava/src/com/google/common/cache/CacheLoader.java#L127).

@LinusDietz LinusDietz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@LinusDietz LinusDietz merged commit c56e1cb into JabRef:master Aug 10, 2017
@koppor koppor deleted the guava_cache branch August 10, 2017 17:37
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.

4 participants