<?php
$memobj= new memcache();
$memobj->connect('127.0.0.1','11211');$memobj->set("name",$arr,false,1); //arr remains the same as foreach
$aa=$memobj->get ('name');
if(!empty($aa)){
echo "read data from mem";
}else{
echo "check data";
}
ob_start()//Open the cache
?>
Remember that ob_start must enable caching