Loading...
There should be two endpoints
- POST /shorten checks for existing short url for given long one and creates a short url
- GET /long looks up the given short url and returns the long version
The short and long url pairs are stored in a relational database while a key value store handles the caching. The server checks the cache and if found redirects otherwise it checks the DB and updates the cache. There needs to be a DB replication in case of outage.
The shorten API uses an base64 encoding to create shorter urls.
The relational DB should only be used if there is a cache miss. If one DB goes down the replica should be used instead.