Skip to content

Instantly share code, notes, and snippets.

@ansulev
Last active November 11, 2020 13:38
Show Gist options
  • Save ansulev/32a2aa8c6dd514b690d08acdb84ba7ce to your computer and use it in GitHub Desktop.
Save ansulev/32a2aa8c6dd514b690d08acdb84ba7ce to your computer and use it in GitHub Desktop.
PHP Memcached Server Test
<?php
// Test default memcached server. Load, then refresh.
if (class_exists('Memcache')) {
$meminstance = new Memcache();
} else {
$meminstance = new Memcached();
}
$meminstance->addServer("127.0.0.1",11211);
$result = $meminstance->get("test");
if ($result) {
echo $result;
} else {
echo "No matching key found. Refresh the browser to add it!";
$meminstance->set("test", "Successfully retrieved the data!") or die("Couldn't save anything to memcached...");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment