>> = sprintf("%.4f", time()) .".". $self->qp->config("me") . \ >> sprintf("%08X", rand(2**32 - 1)); #how expensive is this? >> >> These are the approaches suggested so far. I added the last one as a >> combination of the others. Can we see a show of hands for the one > > Using rand is bogus. A random number generator will repeat values. > > Time (with sufficient resolution) is equivalent to a sequence ... but > with threads, you would need a lock on the sequence generator.
I'm using the poll server which means that there aren't threads to worry about. However the future probably means running multiple daemons to take advantage of multi-core systems so there would need to be a daemon id encoded in there. The big advantage to using time() + id as the least significant digit is that you can put the id in a db server as a double or unixtime which comes in quite handy when you've got a lot of volume. Cheers, ds