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.

Add more control on `maxAge` eviction

See original GitHub issue

Hello, The rule maxAge being checked only on get calls is a bit restrictive to me. In my use case. I use peek to select some elements and then I really use only some of them and call get.

In this way, I keep the last used date accurate to evict the oldest when max is reached. Now most of my elements are never accessed using get and maxAge is not triggered.

What do you think about adding a method to check availability or adding a parameter to get or peek to control maxAge eviction?

It would prevent me for doing this:

// Check manually if the peer is active
if (peers.maxAge && (Date.now() - peers.cache[peerId].modified) > peers.maxAge) {
  peers.remove(peerId)
  continue
}
// Don't mark the peer as most recently used on announce
var peer = this.peers.peek(peerId)

I can propose a PR in this way if you want to.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mafintoshcommented, Jun 10, 2016

i’m gonna release this + the .keys thing as a major bump since its technically changing behaivor

0reactions
yciabaudcommented, Jun 10, 2016

Thank you for your reactivity, making peek respect maxAge fixes my issue. I was not sure this was not the expected behavior of peek.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing how long content stays in the cache (expiration)
You can control how long your files stay in a CloudFront cache before CloudFront forwards another request to your origin.
Read more >
Cache freshness and TTLs - Fastly Developer Hub
Fastly will therefore prefer these over general purpose freshness directives like Cache-Control: max-age when calculating the initial value of beresp.
Read more >
google CDN eviction is too aggressive? - Stack Overflow
Setting an expiration time doesn't affect eviction. As caches receive more traffic, they also evict more cached content.
Read more >
Prevent unnecessary network requests with the HTTP Cache
Developers who do need more control over the HTTP Cache in their web application ... add Cache-Control: max-age=31536000 to your responses.
Read more >
Service worker configuration - Angular
It is recommended that you put the more specific asset groups higher in the list. ... to remain in the cache before being...
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