<?php 
    error_reporting(E_ALL); 
 
    include 'mcache.class.php'; 
 
    echo 'MCache testing...<br>'; 
 
    $cache = MCache::getInstance(); 
 
    # define base where the memory table will be created 
 
    $cache->base('basename'); 
 
    # define your mysql parameters 
 
    $cache->connect('localhost','username','password'); 
 
    echo '<br>Create table for memory cache...'; 
     
    $cache->createTable(); 
 
    echo 'done.<br><br>'; 
 
    echo 'Store variable a=10 with existens of 100 sec. { $cache->store(\'a\', 10, 100); }<br><br>'; 
 
    $cache->store('a', 10, 100); 
 
    echo 'Fetching variable a from cache: a='; 
 
    echo $cache->fetch('a'); 
 
    echo '.<br><br>'; 
 
    echo 'Add array of 20000 elements. { $cache->add(\'array\', $array); }<br><br>'; 
 
    for ($i=1; $i<20000; $i++) $array[]=$i; 
 
    $cache->store('array', $array); 
 
    echo 'Fetch array and check that is equal with stored { if ($cache->fetch(\'array\')===$array) echo \'Fetched array is equal with stored.\'; }<br><br>'; 
 
    if ($cache->fetch('array')===$array) echo 'Fetched array is equal with stored.<br><br>'; 
 
    echo 'Verify that stored variable a exist yet { if ($cache->exist(\'a\')) echo \'Variable $a exist in cache.\'; }<br><br>'; 
 
    if ($cache->exist('a')) echo 'Variable $a exist in cache.<br><br>'; 
 
    echo 'Delete stored array from cache. { $cache->delete(\'array\'); }<br><br>'; 
 
    $cache->delete('array'); 
 
    echo 'Create cache info { $cache->info(); }<br><br>'; 
 
    $cache->info(); 
 
    echo 'Clear the memory cache { $cache->clear(); }<br><br>'; 
 
    $cache->clear();  
 
    $cache->info(); 
 
?> 
 
 |