The Cache_Lite class comes courtesy of PEAR, the PHP Extension and Application Repository (http://pear.php.net). In case you didn't know, PEAR is an online repository of free PHP software, including classes and modules for everything from data archiving to XML parsing. When you install PHP, a whole bunch of PEAR modules get installed as well; the Cache_Lite class is one of them. In case your PHP distribution didn't include Cache_Lite, you can get yourself a copy from the official PEAR Web site, at http://pear.php.net - simply unzip the distribution archive into your PEAR directory and you're ready to roll! Let's begin with something simple - building a primitive cache using Cache_Lite object methods. Here's the code:
Don't worry if it didn't make too much sense - all will be explained shortly. For the moment, just feast your eyes on the output:
Now refresh the page - you should see something like this, indicating that the second occurrence of the page has been retrieved from the cache.
Let's take a closer look at how this was accomplished, on the next page.
blog comments powered by Disqus |