addServer ( $server ); } $memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); //connect to memcached server $link = mysql_connect('localhost','root','secret'); if (!$link || !mysql_select_db('mysql',$link)) { return($link); die('Unable to connect.'); } $sql = "INSERT INTO employee values ('john', 'malkovich')"; $querySuccess = mysql_query($sql); if ($querySuccess === true) { // We build a unique key that we can build again later // We will use the word 'product' plus our product's id (eg. "product_12") $key = 'employee_data' ; // We store an associative array containing our product data $product = array('name' => 'john', 'lastname' => 'malkovich'); // And we ask Memcached to store that data $memcache->set($key, $product); echo "Successfully inserted data to Memcache server"; } ?>