php-ulid icon indicating copy to clipboard operation
php-ulid copied to clipboard

Using monotonic clock

Open CMCDragonkai opened this issue 8 years ago • 4 comments

You can integrate with this: https://github.com/adrianguenter/php-posix-realtime

Not sure about Windows support.

CMCDragonkai avatar Mar 15 '17 10:03 CMCDragonkai

Also the hrtime extension http://php.net/manual/en/book.hrtime.php

Windows support can be done via the COM extension http://stackoverflow.com/questions/23314070/how-to-use-php-com-to-invoke-kernel32-gettickcount

CMCDragonkai avatar Mar 15 '17 10:03 CMCDragonkai

For now I've just tagged it up. The interface exists in the lib for you to extend your own and submit a PR; but I see no problem it's solving so it's not something I've priority to implement. Thanks though :+1:

Lewiscowles1986 avatar Mar 15 '17 10:03 Lewiscowles1986

Cool thanks, the main problem it's solving is to acquire strictly monotonic increasing time, or just increasing monotonic time, because the native time source can either go backwards in time or give you the same time value. Without this, you could get the wrong order for distributed events.

But yes, it would be something for others to include into their PHP if necessary.

CMCDragonkai avatar Mar 29 '17 00:03 CMCDragonkai

I'm open to a PR if you feel up to it. It looks like it's an approach to network time. Honestly I don't use ULID, I read about it and implemented based upon the .NET implementation, then decided after some tests it wasn't right for my business or my software.

Lewiscowles1986 avatar Mar 31 '17 07:03 Lewiscowles1986