note 78022 added to function.memcache-set
| From: | phalcos at osu1 dot php dot net | Date: | Mon, 24 Sep 2007 18:46:51 +0000 |
| Subject: | note 78022 added to function.memcache-set | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130750@lists.php.net to get a copy of this message | ||
Here is a very visual example on how to use the memcache. It sets the key 'time' to the
current time.
Put the example code in an empty page and keep reloading it.
As you can see, after 10 seconds your memcache key will be able to update with a new timestamp.
<?php
$memcache_obj = new Memcache;
$memcache_obj->connect('127.0.0.1', 11211);
if ($memcache_obj->get('time') == "") {
$date = date("H:i:s");
$memcache_obj->set('time', $date, MEMCACHE_COMPRESSED, 10);
}
echo "At ".date("H:i:s").", your key is
".$memcache_obj->get('time');
?>
----
Server IP: 129.16.214.50
Probable Submitter: 83.248.142.57
----
Manual Page -- http://www.php.net/manual/en/function.memcache-set.php
Edit -- https://master.php.net/note/edit/78022
Del: integrated -- https://master.php.net/note/delete/78022/integrated
Del: useless -- https://master.php.net/note/delete/78022/useless
Del: bad code -- https://master.php.net/note/delete/78022/bad+code
Del: spam -- https://master.php.net/note/delete/78022/spam
Del: non-english -- https://master.php.net/note/delete/78022/non-english
Del: in docs -- https://master.php.net/note/delete/78022/in+docs
Del: other reasons-- https://master.php.net/note/delete/78022
Reject -- https://master.php.net/note/reject/78022
Search -- https://master.php.net/manage/user-notes.php