M
M
memba2014-07-16 19:37:02
Algorithms
memba, 2014-07-16 19:37:02

What is the algorithm for generating a message ID on Twitter?

Hey!
Interested in an algorithm or an approximate scheme for generating a message ID on Twitter. For example, we have the following URL: twitter.com/myusername/status/471252841584394240.
How is this number obtained?
In fact, I do not need to compress the ID with some base62, but rather expand it to some fixed length, say 16 integer characters, and thereby have some protection from the "grabber". Here's something similar on Twitter.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2014-07-16
@memba

They had a whole project dedicated to generating these id's on an industrial scale. Now the project is closed, the old code can be viewed in the history of commits. https://github.com/twitter/snowflake
If you think about how you can implement this on your knee, you can use something like
Trim to an acceptable length to taste as an external id.
id will be guaranteed to be unique, because it contains $id and at the same time it is difficult to select by brute force.

A
AxisPod, 2014-07-17
@AxisPod

Get the UUID.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question