<?php
// Memcache
$memcache = new Memcache;
$memcache->addServer('localhost', 11211) or die ('Could not connect');
$memcache->set('mytestvariable', 'this is the data in my test variable', false, 60) or die ('Unable to save the data to the server');
echo 'Data has been stored in the cache<br />';
$result = $memcache->get('mytestvariable');
echo 'Retrieved data from the server:<br/>';
var_dump($result);
// Memcached
$memcached = new Memcached;
$memcached->addServer('localhost', 11211) or die ('Could not connect');
$memcached->set('mytestvariable', 'this is the data in my test variable') or die ('Unable to save the data to the server');
echo 'Data has been stored in the cache<br />';
$result = $memcached->get('mytestvariable');
echo 'Retrieved data from the server:<br/>';
var_dump($result);