예제 #1
0
// 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);
}
// ...otherwise add it
$mc->increment('ultimate', 20);
// increment key
$mc->decrement('ultimate', 8);
// decrement key
echo $question . $mc->get('ultimate');
// echo key
// finish making output readable in browser
echo '</pre>';
// now, let's generate spiffy report :)
echo $mc->report();
// print our custom report