Add more control on `maxAge` eviction
See original GitHub issueHello,
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:
- Created 7 years ago
- Reactions:1
- Comments:12 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i’m gonna release this + the .keys thing as a major bump since its technically changing behaivor
Thank you for your reactivity, making peek respect maxAge fixes my issue. I was not sure this was not the expected behavior of peek.