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

Update: Add BoundedCache for Thumbnails Sidebar #917

Merged
merged 2 commits into from
Feb 8, 2019

Conversation

ConradJChan
Copy link
Contributor

No description provided.

@boxcla
Copy link

boxcla commented Feb 7, 2019

Verified that @ConradJChan has signed the CLA. Thanks for the pull request!

constructor(maxEntries) {
super();

this.maxEntries = maxEntries || 500;
Copy link
Contributor

Choose a reason for hiding this comment

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

why 500?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this is more specific to the application of Thumbnail images, but it's basically arbitrary. I figure if the images are ~50KB 500 would be 25MB of cache which seemed like an ok starting point

// If image is already in cache, then use it instead of waiting for
// the second render image pass
const cachedImage = this.thumbnailImageCache.get(itemIndex);
if (cachedImage && !cachedImage.inProgress) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't we still want to use it even if it's in progress again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if It's in progress, that means there is no generated image yet so there's nothing to insert into the DOM at this point. We add a cache entry with inProgress as true to avoid multiple images being requested

@ConradJChan ConradJChan merged commit ca9b019 into box:thumbnails-sidebar Feb 8, 2019
@ConradJChan ConradJChan deleted the thumbnails-cache branch February 8, 2019 00:08
ConradJChan pushed a commit to ConradJChan/box-content-preview that referenced this pull request Feb 19, 2019
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