To cache or not to cache?13 Dec 2014
Buffers and caches are everywhere. A trash bin can be seen as a buffer; A paper notebook can be seen as your external memory cache. Even the air, acts as a buffer of water (see the clouds? - I mean, the real ones; when it can’t handle anymore, it drains the ‘water’ buffer, and it well - rains)
The same thing happens with all of our digital data. Every bit of it will have a variable value over time, and it may or not make sense to store depending on which point in time you look at it. But not only it matters how long you store it, as well as how often do you need or can exchange it with other systems for which it is useful.
In some cases, buffering/caching is not worth it; In others, it’s a requirement. However, in vast majority of cases, the ideal solutions sits neither in one or the other end of the spectrum, but instead somewhere in between.
See, your pictures might get more valued over time, at the same time that you’ll want to get rid of your bank statement as they get older.
As a system designer, one has to find the right balance whether temporary storage is worth it or not, if yes for what and for how long.
The more the “real time” the requirement is, the less buffers or caches matter. The less the synchronisation frequency or “buffer drain” and the longer the validity of such thing is, the more a caching/buffering solution becomes valuable.
|Nature of Data||Short-Term Value||Long-Term Value||Latency|
|100% Real Time||Highest||Lowest||Minimum Possible|
|No Real Time Needed||Lowest||Highest||Relaxed|
By hitting the right balance, you save resources (processing + storage), while not loosing important information.
In reality, this has been way overlooked and as system developers, we’ve been often comfortable with: well, no network, no go, sorry pal, and synchronization systems were only tasks for the “big guys” with deep pockets.
Indeed for years, creating caching/buffering systems has been a lot of work (let alone do it hybrid - the in between cases). But today I see this picture changing with the introduction of Couchbase mobile.
I will now explore using this framework to create an invisible layer for the common REST Request-Response model found in mobile applications.
The funny thing is, it really happened that while developing the app, my internet connection went down, and I no longer could make my usual http requests to the server. So why not use Couchbase Mobile as a transparent caching layer for all the API calls that are relevant in our time-validity spectrum?
If the results are positive, I’ll suggest integrating the functionality directly in the framework so that one can quickly develop the close-to-perfect hybrid layer of data exchange / caching.