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

Consider changing exact time of expiration in TTLCache #221

Closed
tkem opened this issue Sep 26, 2021 · 0 comments
Closed

Consider changing exact time of expiration in TTLCache #221

tkem opened this issue Sep 26, 2021 · 0 comments
Labels

Comments

@tkem
Copy link
Owner

tkem commented Sep 26, 2021

As @XuehaiPan pointed out in #219 and #220, the current way of determining expiration time is somewhat awkward when using small integer TTLs and/or integer-based timers. For example, with ttl=1, an item will expire at timer() + 2 if timer() returns only integer values. Replacing

link.expire < self.__timer()

with

link.expire <= self.__timer()

throughout ttl.py would probably make this behave more intuitively.

This would be a breaking change, but it is probably safe to expect that most application will use the default timer and shouldn't be affected. Adding another option to the TTLCache constructor for specifying expiration behavior has already been dismissed as too complex.
Note that this will fundamentally change the behavior of ttl=0, but that's probably only relevant for unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant