- The PHP memcache module is an efficient daemon that provides procedural and object-oriented interfaces for memory caching, especially when designing dynamic Web programs to reduce access to the database. Memcache also provides processing for communication dialogs (Session_handler).
- The memcache can be used either under Linux or under Windows systems.
<?PHPHeader("Content-type:text/html;charset=utf-8");$mem=NewMemcache;$mem->connect ("127.0.0.1", 11211) or die("Could Not Connect"); //Show Version$version=$mem-getversion ();Echo"Memcached Server version:".$version." <br> "; //Save Data$mem->set (' Key1 ', ' This is first value ', 0, 60); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val." <br> "; //Replace Data$mem->replace (' Key1 ', ' This is replace value ', 0, 60); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val. "<br>"; //Save Array$arr=Array(' AAA ', ' BBB ', ' CCC ', ' DDD ')); $mem->set (' Key2 ',$arr, 0, 60); $val 2=$mem->get (' Key2 '); Echo"Get Key2 Value:"; Print_r($val 2); Echo"<br>"; //Delete Data$mem->delete (' Key1 '); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val. "<br>"; //Clear All data$mem-Flush(); $val 2=$mem->get (' Key2 '); Echo"Get Key2 Value:"; Print_r($val 2); Echo"<br>"; //Close Connection www.bcty365.com$mem-close ();?>
PHP improves response speed with memcache caching technology