Question

I want to store a large number of unique, indexable urls in mysql. They will be written by the user and will have a really broad acceptance, so almost anything goes there.

But I don't like the already answered SO question nor it's predecessor. Actually I think there might be a 'better' way for doing so, but I don't completely see the implications of this, so that's why I ask this question.

What are the advantages/disadvantages of using tinyurl.com's API for this purpose? In this link we can see an article about how to do this. It's just this code (could be even shorter but I prefer it in a function):

function createTinyUrl($strURL)
  {
  return file_get_contents("http://tinyurl.com/api-create.php?url=".$strURL);
  }

Then I would have to compare only the example in tinyurl.com/example to check the uniqueness of the link. From the wikipedia article we can read:

If the URL has already been requested, TinyURL will return the existing alias rather than create a duplicate entry.

Disadvantages (basically same ones as using any centralized system):

  • Tinyurl servers could go down temporarily or forever. Just in case, the full url will be stored in another not-indexed field.

  • Non reversible. You can get a tinyurl from your url, but the other way back is more difficult. However, first problem's solution also solve this.

  • In my case, the urls are NOT private, but this could prevent someone from using this solution.

  • Delay. The requests might be a bit slower, but since it's server to server talking, I don't think this will be noticeable. Will do some benchmark though.

Any other disadvantage that you can see using this method? The main reason for using it is not to have duplicated entries and to make them indexable.

Was it helpful?

Solution

As the user eggyal suggested, a hash based index of the full URI is really similar to using the Tinyurl API, only I don't need to send data anywhere. I will use that then.

NOTE: this answer is here only to add closure to the question

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top