Expiry System - Alquama00s/link_shrink GitHub Wiki

Deals with expiry/archival of urls

Schedular based

some schedular can be placed at the middleware or database server itself which keeps a timer for each to be expired urls and runs expiry procedure. This system has a lot of memory overhead since storing timer requires space and will grow on order of n.

Trigger based

A trigger can be placed while creating new urls and redirecting urls this trigger will check that particular url and will run expiry procedure if expiry is reached. This sort of system will make url redirection and creation slow also the databse would be unnecesarily cluttered until some requests are made.

Schedular Heap

A Min Heap sorted according to expiry time stamp of a fixed size k is stored on middle ware (service layer) a single thread is used to store a timer till the top of mean heap when the time expires the expiry procedure is run on the url and deleted from the heap and the next url for expiry which is not present in heap is read from database and is inserted in heap. also for every creation of url the url expiry is inserted in heap. O(1) or fixed size space is used for storing urls because of constant size heap and single thread of execution.

More Optimizations

  1. instead of storing time stamps as is it should be rounded of to next minute, and the urls having same rounded time stamps should be grouped together and expiry procedure should be run on all of them at once. With a little loss in preciseness of url expiry time (in seconds) a huge space optimization is achived.
⚠️ **GitHub.com Fallback** ⚠️