Created
September 16, 2018 07:38
-
-
Save gnilchee/37698f29633d0df1b5c23e4a84626dcb to your computer and use it in GitHub Desktop.
php and memcache example
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 | |
$mem = new Memcached(); | |
$mem->addServer("127.0.0.1", 11211); | |
$result = $mem->get("username"); | |
if ($result) { | |
echo $result; | |
} else { | |
echo "No matching key found. I'll add that now!\n"; | |
$mem->set("username", "my_secret_passwd\n") or die("Couldn't save anything to memcached...\n"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment