Well, if everyone else at work takes 2 hour lunches to play cribbage, I'm entitled to work on idkfa during my lunch hour... and a half.
Implemented a caching system, sort of similar to what we had on idkfa v2, but with improvements due to some hard lessons learned previously.
-
On v2, I was caching HTML output, such that whenever you generated something like the "Discussion Item" widget, it saved the structural HTML code for that, and would return that based on a cached file. However, any time I needed to make changed to that HTML code, I would have to find a way to manually clear the cache. This meant that for every change I made, I either had to wait 5 minutes for the cache to clear, or would have to delete a file manually. By the time I was finished with v2, this was a maddening process.
-
Saving the HTML output of a function meant that I never had to spend time processing data again, I could just spit a file back to the user and be done with it. This, however, meant that based on whatever I could be processing, I could be caching a ton of data in order to save the full output. For idkfa v2, that meant all of my super-inefficient HTML was being cached, and sent back and forth, no matter the size of the data set that the output had been generated from.
-
Every function I wrote that I wanted cached I had to do on a case-by-case basis. This means I would have to copy code from one function to another each time I identified a place that could benefit from caching. Not only did this increase the length of the code written, but made it severely complex for which portions should/should not have been cached, and parameters for how to cache it (where to cache, how long to cache, etc.)
Now I'm caching data sets. That is, rather than caching HTML output, I'm caching the data structures returned from the database. And I have two standardized functions to do so (encache, and decache), that support all of the parameters for caching, and those two functions can be used to cache anything (queries, HTML output, whatever I want, really). In addition, because I'm caching queries instead of HTML, I can make improvements using caching without having to worry about whether I'm being called from a normal page load or an AJAX page load (the auto-updating stuff). And being that I can apply caching to anything, and with some ease, I'm hoping to speed things up here in the future for idkfa users.
So far, at least for my kaiden user account, I've taken page loads from 300+ milliseconds down to 70 milliseconds. This is possible because I've been able to make things like generating the Discussion Item widget and Latest Posts widget take near to zero time to process, leaving time instead for more dynamic things like the seen/unseen queries, or the users online queries.