-
-
Save hataiit9x/1dfdf1599dfa9d687aed45c1736b68da to your computer and use it in GitHub Desktop.
Memcached test script
This file contains 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 | |
/** | |
* @license MIT License | |
* @copyright maartendekeizer | |
*/ | |
$memcached = new Memcached(); | |
$memcached->addServer('127.0.0.1', 11211); | |
$name = 'testkey'; | |
$ttl = 10; | |
$data = sha1(time()); | |
$memcached->set($name, $data, $ttl); | |
echo date('His') . ': key "' . $name . '" set to "' . $data . '" with ttl ' . $ttl . PHP_EOL; | |
for ($i = 0; $i < ($ttl + 5); $i ++) { | |
$res = $memcached->get($name); | |
echo date('His') . ': key "' . $name . '" data is "' . $res . '" and that is ' . ($res == $data ? 'a match' : 'not a match') . PHP_EOL; | |
sleep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment