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

[simple-cache-provider] Use LRU cache eviction #12851

Merged
merged 2 commits into from
May 30, 2018

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented May 17, 2018

Max size is hard-coded to 500. In the future, we should make this configurable per resource.

Max size is hard-coded to 500. In the future, we should make this
configurable per resource.
@pull-bot
Copy link

pull-bot commented May 17, 2018

Details of bundled changes.

Comparing: 40ea053...3b51dba

simple-cache-provider

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
simple-cache-provider.development.js +31.4% +28.2% 5.69 KB 7.47 KB 1.84 KB 2.36 KB NODE_DEV
simple-cache-provider.production.min.js 🔺+29.5% 🔺+27.1% 1.26 KB 1.63 KB 650 B 826 B NODE_PROD
SimpleCacheProvider-dev.js +29.3% +27.2% 6.08 KB 7.87 KB 1.88 KB 2.39 KB FB_WWW_DEV
SimpleCacheProvider-prod.js 🔺+35.0% 🔺+32.0% 2.69 KB 3.63 KB 854 B 1.1 KB FB_WWW_PROD

Generated by 🚫 dangerJS

Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

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

Just some minor comments, overall very nice :)

lgtm_goat

map: new Map(),
head: null,
tail: null,
size: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than keeping and updating the 'size' property here, could we rely on the size property of the map attribute of the cache?

Copy link
Contributor

Choose a reason for hiding this comment

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

Going to land this PR, we can fix these in a follow-up.

expect(IntegerStringResource.read(cache, 2)).toEqual('2');
expect(IntegerStringResource.read(cache, 3)).toEqual('3');

expect(() => IntegerStringResource.read(cache, 4)).toThrow(Promise);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just one thing - I think even if 1, 2, and 3 are also evicted I think this will still pass. We could verify that those don't throw Promises?

@flarnie flarnie merged commit ae57b12 into facebook:master May 30, 2018
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

4 participants