I'm Confused with Memcache vs Memcached vs php

2019-01-28 10:36发布

I followed the instruction in this tutorial on how to install nginx, php, and mysql including the php5-memcache.

I'm wondering if I still need to install the memcache or memcached without the "php5" prefix .

As of now my WordPress site is complaining the ff:

The following memcached servers are not responding or not running:

Page Cache: 127.0.0.1:11211.
Database Cache: 127.0.0.1:11211.
Object Cache: 127.0.0.1:11211.
This message will automatically disappear once the issue is resolved.

If it is needed to be installed, will it not conflict with php5-memcache? Or something like an overkill usage of the two version?

And what is the best version to use? Memcache or Memcached? php5-memcache or php5-memcached.

I heard that memcached with "d" is just a service or daemon. But somebody is trying to compare the two as what I have seen here.

2条回答
唯我独甜
2楼-- · 2019-01-28 11:12

memcache and memcached are 2 different servers, each has some features and stuff, you can read the differences as there's so many previous questions about that check google search

The ones starting with php are the extentions used to access the service, just like to use mysql you need php5-mysql, and to use curl you need php5-curl.

So you have php5-memcache for memcache, and php5-memcached for memcached, you can read about what each provide from those links:
memcached lib and memcahe lib

EDIT: Just want to correct the wrong info I wrote above, both php5-memcache and php5-memcached connect to the memcached server, they are just different extensions for the same server, I guess just like php5-mysql vs php5-mysqli

You can still use both together, there's no conflict, but i believe you only need one not both, because most features are available with both, some provide little more features, another candidate service is redis, you should read into that too, it has some features not available in the memcached servers.

查看更多
不美不萌又怎样
3楼-- · 2019-01-28 11:29

The names of these extensions are confusing.

Actually, both php5-memcache and php5-memcached are PHP extensions for working with the memcached service (Memcached server). They both give your PHP processes, the ability to be clients to the memcached service, i.e. to connect to memcached over the network, and to speak the memcached protocol, in order to use the memcached API.

The php5-memcached extension is more stable and has more features in my opinion, so I would suggest, that it should be tried first. Most of its operations are faster too (php source for the benchmark that produced these results).

You still do need the actual memcached service started somewhere, and its address, in order to connect to it. The memcached service may be started on the same host, or on another host/hosts, if you want a distributed cache.

查看更多
登录 后发表回答