3 ms·
For time?
by sly010 10y ago
For time?
- LanceH 10y agoSorry, I couldn't resist.
- monktastic1 10y agoYeah, with a TTL, and on each round you just check the time to see if it's expired.
- throwaway2048 10y agoyeah just call gettimeofday() to see if it expired yet.
- OJFord 10y agoObviously you don't use clock-TTL.
- coldtea 10y agoYes, for time too. For one, if you don't need over second precision, they why have some of your servers e.g. ask for the current time thousands of times per second? There are ways to get a soft expiration that don't involve asking for the time.
- kccqzy 10y agoIn case someone is interested in a concrete example, I first learned about caching time by discovering this package in my dependencies: https://hackage.haskell.org/package/auto-update https://hackage.haskell.org/package/auto-update Its README basically says instead of having every web request result in a call to get current time, it instead creates a green thread that runs every second, updating a mutable pointer that stores the current time.