Nice approach. You didn’t shade light to how you’re going to ensure that the random string remains unique. Consider a scenario where you have a million requests per second, how do you ensure that no url is lost due to duplicate random string.
Great point, Chinedu. I am saving the new random string in the DB table alongside the long URL. If the next request generates the same short string and finds it in the DB when querying it, it will create a new one before returning it to the client. Thoughts?
Cool, I think that makes sense. You'd probably index the random string column to enhance the performance because for every new record, you'd search for a duplicate random string.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice approach. You didn’t shade light to how you’re going to ensure that the random string remains unique. Consider a scenario where you have a million requests per second, how do you ensure that no url is lost due to duplicate random string.
Great point, Chinedu. I am saving the new random string in the DB table alongside the long URL. If the next request generates the same short string and finds it in the DB when querying it, it will create a new one before returning it to the client. Thoughts?
Cool, I think that makes sense. You'd probably index the random string column to enhance the performance because for every new record, you'd search for a duplicate random string.