question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Limit UrlCache, make it an LRU.

See original GitHub issue

What you will need to know

  • Basic Javascript

Background

We have a utility method called parseUrl in url.js that is used to parse a Url string.

This method caches the result of a parse so not to repeat for the same given Url however the cache used for this is unlimited which is no ideal.

Useful Hints

The fix involved changing the cache map to be an LRU (Least Recently Used) cache with a large capacity (100).

Fortunately we have an implementation of LRU cache in lru-cache.js which we can use here.

Step by step

Once approved, your changes will be merged. ⚡⚡⚡Congrats on making your first contribution to the AMP Project!⚡⚡⚡ You’ll be able to see it live across the web soon!

Thanks, and we hope to see more contributions from you soon.

Questions?

If you have questions ask @aghassemi in this issue or on your Pull Request (if you’ve created one) or see the How to get help section of the Getting Started guide.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cjdeleon62commented, Mar 7, 2018

@aghassemi awesome! I’ll start working on it tonight 👍

1reaction
cjdeleon62commented, Mar 6, 2018

@aghassemi I would like to take a shot at this issue if it is free.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What caching algorithm does NSURLCache use?
I'm developing for the iPad, and am hoping to make use of NSURLCache 's disk-caching abilities to cache photos, by using [NSURLCache setDiskCapacity]...
Read more >
LRU Cache Implementation - GeeksforGeeks
Create a class LRUCache with declare a list of type int, an unordered map of type <int, list<int>>, and a variable to store...
Read more >
PageSpeed System Integration - Mod_Pagespeed
The LRUCacheByteLimit is the limit on how large a cache entry the LRU cache will accept. A sample configuration is: Apache: ModPagespeedLRUCacheKbPerProcess ...
Read more >
Caching in Swift | Swift by Sundell
One way to mitigate that problem is to limit the lifetime of our cache entries by removing them after a certain time interval....
Read more >
A Simple LRU Cache Implementation in Swift 5
When the LRU Cache becomes full, the least recently used object of data is bumped out to make room for the new object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found