3 ms·
Another way to make unique ordered keys is to use a timestamp and append a random value, such as a random UUID. key = timestamp + UUID4
by mleonhard 16y ago
Another way to make unique ordered keys is to use a timestamp and append a random value, such as a random UUID.
key = timestamp + UUID4
- j_random_hacker 16y agoI didn't like this idea at first, since it struck me that if for some reason you had to create many records in quick succession (e.g. some kind of bulk upload) they would essentially be placed in random order. But thinking about it, the only scenarios where you would need to do this and want to preserve the order exactly would be if all the records were coming from the same source -- in which case you could just choose a single UUID for the batch and append increasing values of a local counter to this. TL;DR: This would actually work really well I think!
- bmm6o 16y agoIsn't this exactly what the article suggests doing? Time stamp + user id + comment count.