* caching the return from any function
* caching any datastructure you pass to it.
One issue with Cache_lites implementation of these two capabilities is that they come from different classes. If you need to cache a function return, you need to require Cache/Lite/Function.php first. If you want to cache a data structure, you need to require Cache/Lite.php prior. Also the function caching syntax seemed a bit unintuative to me.
To aleviate these issues I wrote a smaller wrapper class that unifies and symplifies the usage of the Cache Lite class(es).
This allows the client code of cache wrapper to simply call getCall(), getData(), and saveData() without needing to know that different base CacheLite classes are involved.
Also I put in a bit of code to allow for a bit of leway on the accepted formatting of function string parameters given to getCall();
Example Usage
For any function you want to add 'cacheability' to, you can add an optional param of...
$cacheTTL = CachWrapper::DEFAULT_CACHE_TTL
You then code similar to the first two lines of the exaple method below. Note you can supply a cacheTTL of 0 to essentually make an un-cahced call to the method.

0 comments:
Post a Comment