Timebased expiration cache which expires at full intervals (like at full hours).
Closed this issue · 1 comments
Let me also assure you that you didn't "hit a weak spot" - there are no issues with the TTLCache implementation, at least none I'm aware of.
Then i don't understand your defensiveness about this topic - but i understand you'd like to have this topic closed, which works fine for me.
Unfortunately, continuation of locked issue #219 as that topic is not closed, since the provided solution sample is apparently not one you think will properly work (and you also think should be done differently).
To be very clear, i'm not interrested in the "remaining" discussion you deemed as hot heated - but on the technical solution, also because i think this type of cache would be a great addition to this Project (obviously done the way you think will be best).
I do have a working implementation (the one shared in #219 (comment)) - which is fully covered by tests (including ones that shift time) and i know works correctly as i tested it extensively.
I'd be happy to contribute this here, but from #219, i did understand that you're not interrested in having this (either because it doesn't fit the project, or because it's subclassing the wrong class) - which is fine for me (i can keep this in my project without problems).
Finally, use of inheritance in the example above was marked as "for exposition only". I would probably use a separate accessor function, but to keep this short and since you seem to like inheritance, I tried to do you a favor.
Again, attacking users without reason (you might not mean it this way, but your wording implies that you think the way is wrong, which is a form of attack -> please calm down before answering to this issue)
It's not about liking inheritance or not - but about a good technical solution without a lot of code duplication (you seem to reject inheritance - which can also lead to biased results and a lot of code duplication).
You point out that the only class to be inherited from would be Cache
- which is fine for me if that can get my goal archived without copy/pasting 90% of another class.
How would this then be implemented properly, inheriting only from Cache
?
I'm not that familiar with internals of cachetools - so if you have a pointer (or better yet, a working solution in the way you think it should be done) i'd be grateful for that.
The provided FullHourCache
sample does hardcode 1h cache, which is clearly not the request / topic.
As stated before, I think using a custom timer
with sufficiently large "tick intervals" (hours, days, etc.) should be an option. Note that in cachetools
v5.0.0, TTLCache
's expiration algorithm was adapted to make use of small ttl
values with large tick intervals a little more intuitive (#221).
OTOH, you might prefer to use TLRUCache
, also introduced in v5.0.0, which provides for absolute, per-item expiration times.