Mon Jul 23, 2012 10:10 pm
$memoryCacheObj = new Memcached();
// assuming you have a memcached daemon running in the local system
// port defaults to 11211
$ memoryCacheObj ->addServer("localhost", 11211);
// cache value
$ memoryCacheObj ->set("username", "codemiles");
// get the cached value
print $memc->get("username");
$memc = new Memcached();
$memc->addServer("10.20.1.2", 11211);
$memc->addServer("10.20.1.3", 11211);
// set a value & specify the data to expire in 7 minutes
$memc->set("username", "codemiles", 7 * 60);
// replace the value of the existing key, but not modifying the expiry time
$memc->replace("username", "codemiles");
// append data to an existing value
print $memc->append("username","as");
// set multi-able elements
$data = array(
'username' => 'codemiles',
'city' => 'newyork',
'age' => '33');
// set the multi elements array and set to expire 7 minutes from now
$memc->setMulti($data, time() + 7 * 60);
// get multiple elements
$dataCached = $memc->getMulti(array('username', 'city', 'age'));
session.save_handler = "memcached"
session.save_path = "hostname:port"
http://pecl.php.net/package/memcached
|
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.