in reply to Re: Long url to tiny url.
in thread Long url to tiny url.
If not, you use some random method to generate tinyURLs until you get one that's not already in your database ...
Personally (i.e. I don't know if they are doing that way), I would just count issued tinyURLs (the count might come directly from the database), and represent that number in some number base, e.g. 62 for the printable chars you've specified.
The advantage would be that it's simpler in the following ways: (1) I wouldn't have to check whether some randomly generated number is already in use, and (2) would be able to have the number of required digits grow just as needed, so the tinyURL is always as compact as possible. (With a random number, I'd have to choose ahead what width to use. Also, as full utilisation of the set is being approached, searching for a remaining free number would require more and more iterations...).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Long url to tiny url.
by Polonius (Friar) on Jul 07, 2007 at 14:45 UTC | |
by almut (Canon) on Jul 07, 2007 at 16:10 UTC | |
Re^3: Long url to tiny url.
by RMGir (Prior) on Jul 07, 2007 at 10:49 UTC |