2

We use PHP 7.4 and recently our build went from APCu version 5.1.21 to 5.1.22, with changelog noted here

We noticed that the internal timestamps for the cache object have changed from a prior UNIX Timestamp value to some sort of low-value integer (e.g. 5347 or 75632) - which of course isn't a valid UNIX TS and formats to Epoch time. Which makes our APCu 'info' page tool look broken.

Is this a side effect of the changelog item - Use monotonic clock for TTL ?

So, nothing to worry about other than we can't translate to a useable date/time string?

C C
  • 419
  • 1
  • 4
  • 18
  • See: https://stackoverflow.com/a/3527632/1064767 I believe that [`hrtime()`](https://www.php.net/manual/en/function.hrtime.php) will get you the current value of the monotic clock for math/comparison, but I don't know how advisable this all is. If you need to track the time of a cache entry I would suggest embedding a timestamp in the cached data. What is this "APCu 'info' page tool", and what "looks broken"? – Sammitch Oct 27 '22 at 23:19
  • I should add that the reason why they switched to the monotonic clock seems to be to avoid cache TTL issues during DST changes, leap seconds, and various other potential changes to the clock. [The issue that led to the PR that implemented monotonic time.](https://github.com/krakjoe/apcu/issues/412) – Sammitch Oct 27 '22 at 23:20
  • There's a script that gives insights into APCu and some functionality (like full/selective cache entry eviction) - here: https://github.com/krakjoe/apcu/blob/master/apc.php -- it shows all the dates as 1970 now. Not a big deal now that my understanding is confirmed. Thank you for the link to the detailed explanation for monotonic time. – C C Oct 28 '22 at 13:30

1 Answers1

0

In apc.php, try displaying dates/times using time() and hrtime() offsets, e.g.,

date(DATE_FORMAT,$entry['access_time']+time()-hrtime()[0])
Blair
  • 1