note 78022 modified in function.memcache-set by danbrown

From: Date: Sat, 19 Jun 2010 03:59:08 +0000
Subject: note 78022 modified in function.memcache-set by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170277@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'); ?> --was-- 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'); ?> http://php.net/manual/en/function.memcache-set.php

« previous php.notes (#170277) next »