$tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo"Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key'); echo"Data from the cache:<br/>\n"; print_r($get_result);
输出:
1 2 3 4
Server's version: 1.2.6 Store data in the cache (data will expire in 10 seconds) Data from the cache: stdClass Object ( [str_attr] => test [int_attr] => 123 )