php-using Memcache in PHP

Source: Internet
Author: User

<?php  phpinfo ();? >

Check to see if PHP on your PC already has the Memcache extension installed.

If not:

(1) PHP Installation path Find ext folder

Mine is C:\wamp\bin\php\php5.5.12\ext.

Put the downloaded Php_memcache.all file in

(2) in the PHP.ini configuration file, add

Extension=php_memcache.dll

(3) Restart the server

I have a problem with the reference to the https://www.oschina.net/question/1254404_248665

With the Php_memcache-3.0.8-5.5-ts-vc11-x86.zip

Common functions:

For details, refer toPHP Manual "lxxxiv. Memcache Functions "this chapter.
  Memcache Common object-oriented interfaces include:
  Memcache::connect--Open a connection to Memcache
  Memcache::p Connect--open a long connection to Memcache
  Memcache::close--Close a Memcache connection
  Memcache::set--Save data to the Memcache server
  Memcache::get--Extract a data stored on the Memcache server
  Memcache::replace--Replace an item that already exists on the Memcache server (functionally similar to memcache::set)
  Memcache::d elete--delete a saved item from the Memcache server
  Memcache::flush--Refreshes all items saved on the Memcache server (similar to deleting all saved items)
  Memcache::getstats--Get the status of the current Memcache server running
  Memcache::addServer--Distributed server add a server

<?php  $mem =new Memcache;  $mem->connect ("localhost", 11211);  $mem->add ("MyStr", "This is a Memcache test!", memcache_compressed,3600);//  $mem->set ("MyStr", " Wwwwwwwwwwwwwwwwwww ", memcache_compressed,3600);  $str = $mem->get ("mystr");  echo "string:". $str. " <br> ";  $mem->add ("Myarr", Array ("AAA", "BBB", "CCCC", "dddd"));  Print_r ($mem->get ("Myarr"));  Echo ' <br> ';  Class person{    var $name = "Zhangsan";    var $age =10;  }  $mem->add ("myobj", new person);  Var_dump ($mem->get ("MyObj"));  $mem->close ();? >

  

Where to use Memcache in PHP

First, the database read out data (select) using memcache processing

Ii. use in Session control sessions

Memcache security (not accessible to others)

1. Intranet

2. Set up a firewall

php-using Memcache in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.