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