Skip to content

Instantly share code, notes, and snippets.

@ruliarmando
Created March 8, 2013 01:56
Show Gist options
  • Save ruliarmando/5113640 to your computer and use it in GitHub Desktop.
Save ruliarmando/5113640 to your computer and use it in GitHub Desktop.
a script to test if memcache works
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment