-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Time unit of Expiry#expireAfterCreate currentTime #441
Comments
We only use relative time and assume time is monatomic, so nanoTime is the right fit. If you need to calculate the duration based on wall clock time, e.g. offset from an external resource's calendar time, then you'll need to obtain that reading yourself. For example if you cache geocode results for 30 days in a db, then you'll need to take use the wall clock time with the For testing you can use Guava's FakeTicker. If you need wall clock time, then use |
Yes, |
|
Ok, thanks! |
Hi,
I am trying to set expiry time of an entry depending of the current time and entry time.
I want the solution to be testable, so I wanted to use provided in arguments current time.
It is said in doc that
currentTime
is in nanobut, I am checking that with the following code:
and the result is
as you see
currentTime
in args is17701871302300
, taking system current time in nanos is1596437734903000000
, which is about 90k times more.So, what is the real unit? To be honest, I did not debug it internaly. Hovewer, I am using the standard ticker you provided, which seems to use
nanoTime
, so in general the question is - how to externalize it, and is it possible without any workarounds on theTicker
?.Thanks
The text was updated successfully, but these errors were encountered: