Php cannot operate memcache-php Tutorial

Source: Internet
Author: User
Php cannot operate on memcache. my phpinfo () shows that memcache is available for memcached services. Why can't php code operate on memcache? I don't know where to troubleshoot the problem. thank you for your advice.
$memcache = new Memcache();//var_dump($memcache->connect('localhost', 11211));die;if (!$memcache->connect('localhost', 11211))  die('could not connect');$memcache->set('key', 'test');$get_value = $memcache->get('key');echo $get_value;       

The php returned absorted status when accessing the webpage.


Reply to discussion (solution)

Phpinfo () shows that memcache has started with the memcached service.

Memcache and memcached are different.

The background process checks whether the server is normal.

Phpinfo () shows that memcache has started with the memcached service.

Memcache and memcached are different.




Memcache is a client and memcached is a server service.
I said that there is memcache in phpinfo (). I just want to express the php memcache extension. I have already installed it.
Now the problem is that the extension is installed and the service is started. php still cannot operate on memcache ~

The background process checks whether the server is normal.



I confirmed that the server is normal.
I use telnet localhost 11211 to connect to memcache and perform storage and read operations.

Currently, php cannot operate on memcache.

The absorted status should be that the client is disconnected, rather than the server is disconnected.
Multi-occurrence and browser

Php code alone does not.
It is recommended that you first confirm that the php error check is not closed and the error display is on

The absorted status should be that the client is disconnected, rather than the server is disconnected.
Multi-occurrence and browser

Php code alone does not.
It is recommended that you first confirm that the php error check is not closed and the error display is on



 Connect ('localhost', 11211) die ('could not connect '); $ memcache-> set ('key', 'test '); $ get_value = $ memcache-> get ('key'); echo $ get_value;


Add the fifth line die (); the browser is not in the absorted state, and the returned object (Memcache) #1 (0 ){}
The problem found in subsequent debugging lies in $ memcache-> connect, which leads to absorted.

Change localhost to 127.0.0.1.

Echo $ memcache-> getVersion ();
You can also see whether it is normal

Echo $ memcache-> getVersion ();
You can also see whether it is normal



The same error occurs when you change to localhost.
$ Memcache = new Memcache ();
Echo $ memcache-> getVersion ();

In this case, the following error occurs: Warning: MemcachePool: getversion (): No servers added to memcache connection in xxx line 5.
I tried $ memcache = new Memcache (); $ memcache-> addserver ('2017. 0.0.1 ', 127); still absorted

$ Memcache = new Memcache ();
$ Memcache-> connect ('localhost', 11211 );
Echo $ memcache-> getVersion ();
If no connection is established, an error is returned.

I re-launched a stable version of memcache to solve the problem.

: Http://pecl.php.net/package/memcache

Related Article

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.