Address
Whiteland, IN 46184
Work Hours
Monday to Friday: 9AM - 5PM
Weekend: 1PM - 3PM
During the early days of coding, caching was not something that came to mind while I wrote code. The goal of writing the code was simply to get it working, but as you begin to grow you find out that what you thought you knew before you actually have not idea what it is about.
What is Caching? In simple terms caching is simply saving a particular result in memory so the computer does not have to do the work of calculation or a lot of computation to bring out that particular result.
Let’s use a simple math problem to illustrate what I mean. What is 2+2? most people if not all who have passed the level of nursery school will answer 4 right? under let’s 2 milliseconds. This is because people at this level have the answer of 2 + 2 stored in memory so they don’t have to do the calculation to solve it. Now let’s ask a nursery child who is still being taught maths 2 + 2. He or She probably asks for a pencil to draw 2 lines on a piece of paper and draw another two lines and then proceed to count (In the child’s way of dragging lines)1, 2, 3, and 4!!! The child can also use his or her fingers to count. Now if we compute the time the child uses to get the answer to 2+2, we can see the time is significantly greater than when a person has the answer in memory, catch my gist : ).
This same principle goes for the computer, parts of or whole sets data, that isn’t changed often should be stored in the cache memory so the computer does not have to do a lot of computation to get the same result again. Caching enhances performance as it decreases access time to a resource. So this means the computer fetches data from memory instead of having to query the database each time a request is made. The cached data can always be updated so it does not have to be outdated data.
So what are the advantages of caching?
I hope the little write up gives a little insight into why we as developers should try caching.