Caching And Organizing. A dilemma?
4 min read

Caching And Organizing. A dilemma?

Caching And Organizing. A dilemma?
Photo by Jeff Sheldon / Unsplash

Perhaps one of the most important and overlooked concept in computer science is Caching. Caching without a doubt is one of those computer science concepts that has helped me in organizing my life for the better.

Caching, merely is just another scheme or a technique to organize digital information for faster access when needed. But how can this be applied to our daily lives, you might wonder. The amount of relate caching has in organizing not just digital information but also physical information is quite impeccable. Who knows, maybe you have been following the underlying principle of cache all these days and you didn’t even realize that it’s computer science again that made your life easier.

Let’s say you have a book that definitely needs to be checked up everyday. It is quite obvious for you to keep this book just on top of your desk on in one of your desk closets as this inherently facilitates to quick retrieval. You obviously don’t want to keep this book back in your book shelf that you don’t touch if not just for this book. This is exactly what Caching aims to offer, quick and efficient retrieval.

But the problem is, what happens when you don’t have a compartment to store books in your desk table or what if your desk storage is full already and it can’t hold this book you definitely need to checkout everyday. This problem applies to Caching in computer science as well and of course we need to evict an item from our desk and replace that item with our book. But what item do I remove ?

There are different types of eviction techniques when it comes to evicting items from cache store when it is full. The first and the most simplest is Random Eviction where you just toss off an item at random from the cache store. The second strategy is FIFO (First In First Out) where you evict the first time that you had put in your desk. This also means tossing out the oldest item that entered your desk, paving way for the new one. The third idea is called LRU (Last Recently Used) where you evict an item that’s gone long untouched.

Of course, the Random Eviction is probably the easiest and most compelling things to do as you don’t need to analyze anything and just pick one item at random from your desk and evict that. FIFO looks to be logical at first as it is quite understood that you also want to remove the oldest item from your desk. But LRU happens to be the most effective principle. The reason why it is so is because of “Temporal Locality”. Temporal Locality states that if you have recently accessed a piece of information, it is more likely that you will access the same item in your near future. Correlate this with LRU and you shall understand why it’s the most optimal and effective principle to follow. A straight forward example to understand Temporal Locality is possible when you intend to switch tabs in your machine. Isn’t it quite obvious that you might definitely return to the tab from which you switched to another ?

So if LRU is the most optimal principle to follow, then does make sense not to throw that old tee that you have been using for ages since the first year of college probably and throw that rich suit that you last used for somebody’s marriage function ? Clearly not, and you might also not want to. This once again results in a dilemma and now you wish for a better strategy to exist.

This is where Multi Level Caching comes into place along with the geography of things. Now, geography is also another very important attribute you want to associate Caching with. Multi level Caching doesn’t let you have your tees and suits organized in once place and rather gives them two separate spaces in your wardrobe. Now if you apply LRU, it makes sense to keep that old tee and rather throw away another tee you probably bought after this old tee you are wearing now. The reason you’re throwing this relatively new tee is because you haven’t used that for a longer period of time and the reason you haven’t used it for a longer period of time might be due to a lot of factors such as colour, design and size.

Before talking about how geography comes into play here, I quickly want to narrate an incident that happened in home quite recently. Dad always leaves the nail cutter near handwash and Mom resents not placing the cutter back from where he initially took it. Dad argues ( probably with a little bit of laziness hanging around ) that it makes sense to have the cutter near handwash as you might want to first handwash and then cut your nails and wash hands again. So for easier use, it makes sense. But Mom likes to keep everything in a place where it’s supposed to belong and freaks out if things are not in place. And this explains geography. Geography essentially means having commonly used items closer to your place for easier retrieval. With this, it does make sense to probably leave that cutter near handwash and also have a valet stand just near your bed, but this certainly won’t be chapter in one of the popular home organization books.

But after all, if you think about it, you want to organize things so you can access them with ease right?