Ok, admittedly, data caching isn't that difficult of a coding structure to implement if you're looking to hold a value until the program restarts, or you pick a clever location to scope your variable. You just declare it somewhere that it will stick around for as long as you want, pull the value if it's blank, and if it's not blank then use it instead of pulling it. Not a difficult pattern.
However, as soon as someone says "Rolling Cache" or "Limited-Time Cache", it introduces a time-out check, and you have to track the last time the cache(s) were used and/or when they were created, and it could create a memory leak, or a thread locking issue, or concurrency issue, or god only knows what the heck else.
That is where the GDAC's caching mechanisms come in. The GDAC is capable of holding an unlimited number of rolling and/or forced time-out caches. It monitors them consistantly with a timer wheel pattern to eliminate expired caches, while also not using any excess processor cycles on non-critical timer object elapse events. It is compatible with parameters and will hold different cached values for different supplied parameters, and if a matching cache is found and used, a database connection is not even procured unless logging is enabled.
A rolling cache is a cache that stays alive as long as it is used within the time period. This type of cache is great for situations where you know a query is going to be run several times in a short time period, but then will no longer be used for a long period after the burst.
A Limited-Time cache (or Force-Delete cache), is a cache that is always deleted so many seconds after it was first created. This type of cache is useful for an extremely heavy use query that needs to update occasionally whether the user(s) are using it or not.
Both of these systems can be combined as well, with the Force-Delete cache providing a final time limit for the cache, with the rolling-cache time providing an early-delete timeout if the user(s) are no longer using it to free up server memory.
To enable the caching timer wheel and caching checks, you have to first activate it during the creation of the class:
Then you can use the caching in queries (note that the numbers are in seconds, and when using parameters you must specify whether the select statement is truely a select, or really a stored proc that does both insert/update/delete and selecting):
Occasionally it is neccessary to delete a cache. In the above example, if the user modified their first name in the database, you would need to delete that cache or the user is going to be very confused why it never takes effect. The GDAC has two overloads for deleting caches. One accepts no parameters and deletes all caches. The other searches through the caches and only deletes the ones with a text match.