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.

What about a ExpirationPolicy.ONLY_IF_ACCESSED?

See original GitHub issue
  1. entry expires only if it has been accessed
  2. this could be useful especially in conjunciton with .maxSize to expire entries only a set time after they have been accessed but maxSize prevents the map from growing out of control
  3. in some unpredictable situations (like waiting for responses across the network), this could be useful when you need to keep some data in a map until you receive a confirmation request. Then you don’t need it for much longer afterwards because your code is not depending upon external slowdown factors

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Nohuscommented, Nov 4, 2017

This would indeed be useful, with such a policy there would be no need for any timers/threads. The expiration time would only be checked when the entry is accessed to check if it should be returned or not. It would decrease the overhead and complexity of the ExpiringMap while still being useful when the map size growing too big is not a concern.

0reactions
mishaxzcommented, Apr 22, 2017

nah, I was just thinking leave it in the map… and if it is never accessed, it never expires. However, to prevent it from growing out of control the user could set maxSize to have it expire entries that way (just in case)

however, probably a good idea to throw an exception if maxSize is not set to be very safe )

ok maybe this feature is a “would be nice” thing that could cause problems…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class ExpirationPolicy (2.13.11) | Python client library
ExpirationPolicy(mapping=None, *, ignore_unknown_fields=False, **kwargs). A policy that specifies the conditions for resource expiration (i.e., ...
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