Skip to content
brianhaveri edited this page Sep 14, 2010 · 6 revisions

What is MiniCache?

MiniCache is a small, lightweight PHP5 cache system made for novice to intermediate developers, or skilled developers that don’t demand the full feature set of memcached or APC.

Why use MiniCache?

  • You are dynamically generating HTML strings, but it can be slow and hinder performance. You can use MiniCache to store the generated HTML string.
  • You want to save the state of a PHP object. MiniCache can save the entire object for later reuse.
  • You want to parse data from multiple sources into a PHP array. MiniCache can act as a central data storage location, keeping your memory footprint lower.

Getting Started

  • Set cache directory
  • Open MiniCache.php and edit line 23 to an absolute path that exists on your system. Example:
    private $_path = ‘/myproject/cache/’; // Path MUST exist, be writeable, and include trailing slash

Sample Code

require('MiniCache.php');
$data = array('red', 'blue'); // Sample data. You can store any datatype (array, object, string, etc.)
$mc = MiniCache::getInstance();
$mc->set('colors', $data);
print_r($mc->get('colors')); // Array( [0]=> red, [1] => blue )
Clone this wiki locally