function cacheTest($ok, $notok) { /* echo microtime() . "<br>"; usleep( 2000000 ); echo microtime() . "<br>"; */ try { echo "(" . microtime() . ") Testing cache <br>"; $start_microtime = microtime(); $cache1 = new myCache("c1"); $cache2 = new myCache("c2"); echo "Fetching an object from cache1<br>"; $obj1 = $cache1->get("obj1"); echo "This is what we have: " . $obj1 . "<br>"; $obj1 = $obj1 == NULL ? 0 : ($obj1 = $obj1 + 3); echo "Now setting with new value: " . $obj1 . " (+3)<br>"; $cache1->put("obj1", $obj1, 0); echo "Fetching an object from cache2 - using the same object name 'obj1'<br>"; $obj2 = $cache2->get("obj1"); echo "This is what we have: " . $obj2 . "<br>"; $obj2 = $obj2 == NULL ? 0 : ($obj2 = $obj2 - 2); echo "Now setting with new value: " . $obj2 . " (-2)<br>"; $cache2->put("obj1", $obj2, 0); echo "incrementing by 7<br>"; $inc_res = $cache2->increment("obj1", 7); echo "inc result: {$inc_res}<br>"; echo "incrementing by 6<br>"; $inc_res = $cache2->increment("obj1", 6); echo "inc result: {$inc_res}<br>"; $end_microtime = microtime(); echo "(" . microtime() . ") Test took [" . ($end_microtime - $start_microtime) . "] seconds"; echo $ok; } catch (Exception $e) { echo "Problem with your memcache installtion"; echo $notok; } }