-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support durations for TTL #2
Comments
Hello,
Thanks for the report.
I'd like to use durations for TTL, but they are not @safe. I'll check again.
The same problem with other time functions.
I didn't find any better solution than use time(null) and plain seconds.
If there is safe solution I can change struct TTL implementation to use
durations.
Will be thankful for any hints here.
пн, 14 янв. 2019 г., 1:40 Jan Jurzitza notifications@github.com:
… The TTL settings for cache entries should support core.time : Duration,
which makes the code more readable (5.seconds, 10.minutes) and also
supports more accurate values than seconds.
You could also replace the time calls with MonoTime (from core.time)
which can give you durations relative to two MonoTime values
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABNuSQ-YBhbHAb186xEdzJqiPsa6VGHrks5vC8PcgaJpZM4Z9cUG>
.
|
the Duration struct and all its functions are |
My fault. |
Hello @WebFreak001 , It turns out that MonoTime.currTime is much slower than time() (see below), so current plan is: to use Duration in API calls to increase readability, but internally use only one second resolution for TTL and use fast time() call to trace expiration. It seems that 1 second resolution for ttl is enough.
give output (https://run.dlang.io/is/jiMvs4)
Any objections? |
You can use How often are the time functions called anyway? Would it even make any performance impact? |
Hello, @WebFreak001 I pushed all changes to master.
time functions called on each Yes, there is some performance impact, but we can't avoid it. Code
produce next timings (ldc2, -release):
When ttl enabled:
If everything is ok, I'll close this issue. |
You could cache the value of MonoTime.currTime in the cache functions right? There is not a lot of delaying logic inbetween the calls and a difference of a few usecs wouldn't make it fatal I think, considering before seconds were the only supported accuracy. Otherwise the changes seem to work good 👍 |
Ok, I'm closing this. Would like to fix remove safety restrictions. |
The TTL settings for cache entries should support
core.time : Duration
, which makes the code more readable (5.seconds
,10.minutes
) and also supports more accurate values than seconds.You could also replace the
time
calls with MonoTime (from core.time) which can give you durations relative to two MonoTime valuesThe text was updated successfully, but these errors were encountered: