Last active
November 11, 2020 13:38
-
-
Save ansulev/32a2aa8c6dd514b690d08acdb84ba7ce to your computer and use it in GitHub Desktop.
PHP Memcached Server Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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