include 'classes/class_MemcacheManager.php'; // creat memcache object $mc = new MemcacheManager(); // add servers $mc->addserver('localhost', 11211); $mc->addserver('localhost', 11212); $mc->addserver('localhost', 11213); // create some date to store $init_data = array('username' => 'memcachehater', 'email' => '*****@*****.**', 'displayname' => 'Memcache Hater', 'location' => array('country' => 'USA', 'state' => 'Missouri', 'city' => 'St. Louis')); $replace_data = array('username' => 'memcachelover', 'email' => '*****@*****.**', 'displayname' => 'Memcache Lover', 'location' => array('country' => 'USA', 'state' => 'Oregon', 'city' => 'Portland')); // start making output readable in browser echo '<pre>'; // store data $mc->add('memcachelover', $init_data, 0, true, true, true); // adds the key with JSON encoding, encryption and compression $mc->replace('memcachelover', $replace_data, 0, true, true, true); // replaces the key with JSON encoding, encryption and compression // retrieve data echo $mc->get('memcachelover', false, false, true) . "\n\n"; // echo the uncompressed, but still encrypted key echo $mc->get('memcachelover', false, true, true) . "\n\n"; // echo the uncompressed, decrypted JSON formatted string print_r($mc->get('memcachelover', true, true, true)) . "\n\n"; // print the uncompressed, decrypted array // test increment and decrement $question = "the answer to life the universe and everything = "; if ($mc->get('ultimate') != '') { $mc->replace('ultimate', 30); } else { $mc->add('ultimate', 30); }