1<?PHP2 /**3 * memcache::add-Add an entry to the cache server4 * memcache::addserver-Adding a Memcache server to the connection pool5 * memcache::close-Closing the Memcache connection6 * memcache::d elete-Delete an element from the server7 * memcache::get-checking back an element from a server8 * memcache::set-storing data on the server9 * memcache::flush-Cleaning (deleting) All the elements that have been storedTen * memcache::getstats-getting server statistics One * Memcache::p connect-to open a persistent connection to the server A * memcache::replace-Replace the value of an already existing element - * Compress the data using the memcache_compressed tag (using zlib). - * memcache::connect-Open a memcached server connection the * Installation of the same project two times, key to have a prefix - * Memcache Security (no one else to visit) - * Intranet, set up firewall, - * iptables-a input-p TCP 192.168.1.111-dport 11211-j ACCEPT + * iptables-a input-p UCP 192.168.1.111-dport 11211-j ACCEPT - */ +$men =NewMemcache;//instantiate a class of Memcache A //Var_dump ($men);//returns an object (Memcache) [1] at$men->addserver ('127.0.0.1',11211); -$men->add ('mytest','today is Tuesday');//writing data to the Memcache -$menSet('mytest','22today is Tuesday');//overwrite the original key with the same name -$str = $menGet('mytest');//read the data from the Memcache -$men->add ('Mytest2','today is Tuesday Woo');//writing data to the Memcache -$men->add ('myarray', Array ('AAA','BBB','CCC','DDD')); in$rs 2= $menGet('Mytest2'); -$rs 4= $menGet('myarray'); toecho $rs 2;//today is Tuesday Woo +$men->replace ('Mytest2','today is Tuesday Woo 2222'); -$rs 3= $menGet('Mytest2'); theecho $rs 3;//today is Tuesday Woo 2222 * Var_dump ($rs 4); $ /**Panax Notoginseng * Array (size=4) - 0 = String ' aaa ' (length=3) the 1 = String ' BBB ' (length=3) + 2 = String ' CCC ' (length=3) A 3 = String ' DDD ' (length=3) the */ + //echo $str;//today is Tuesday 22today is Tuesday -$rs = $mengetstats (); $ //Var_dump ($rs); $ /** - * Array (size=20) - ' pid ' = String ' 1984 ' (length=4) the ' uptime ' = String ' 1474 ' (length=4) - ' time ' = = String ' 1427158094 ' (length=10)Wuyi ' version ' = = String ' 1.2.6 ' (length=5) the ' pointer_size ' = String ' + ' (length=2) - ' curr_items ' = String ' 2 ' (length=1) Wu ' total_items ' = String ' (length=2) - ' bytes ' = String ' 153 ' (length=3) About ' curr_connections ' = String ' 4 ' (length=1) $ ' total_connections ' = String ' 5 ' (length=1) - ' connection_structures ' = String ' 5 ' (length=1) - ' cmd_get ' = String ' (length=2) - ' cmd_set ' + string ' (length=2) A ' get_hits ' = String ' (length=2) + ' get_misses ' = String ' 0 ' (length=1) the ' evictions ' = String ' 0 ' (length=1) - ' bytes_read ' = String ' 2697 ' (length=4) $ ' bytes_written ' = String ' 3681 ' (length=4) the ' limit_maxbytes ' = String ' 67108864 ' (length=8) the ' Threads ' = String ' 1 ' (length=1) the */ the - classperson{ in var$name ='Zhangsan'; the var$age =Ten; the } About$men->add ('myobj',NewPerson ); the$myobj = $menGet('myobj'); the Var_dump ($myobj); the /** + * Object (person) [2] - Public ' name ' = = String ' Zhangsan ' (length=8) the Public ' age ' = intBayi */ theecho $men->getversion ();//1.2.6 Version number the$menclose (); -?>
The use of memcache in PHP