0

When I save some data on one server using the memcached PHP client library, and try to read it from another server using the memcache (no D) PHP client library, it seems to get a lot of garbage characters in there.

I've tried setOption(Memcached::OPT_BINARY_PROTOCOL, true) on the memcached side of things, to no avail.

Here are the settings we have for the memcached library:

$memcache_obj->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
$memcache_obj->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcache_obj->setOption(Memcached::OPT_CONNECT_TIMEOUT, 50);
$memcache_obj->setOption(Memcached::OPT_SERVER_FAILURE_LIMIT, 2);
$memcache_obj->setOption(Memcached::OPT_NO_BLOCK, true);

Why do we need this? We used a mixed server environment, where we require Windows and Linux web servers. However, there is no precompiled memcached PHP client DLL for Windows (see Does memcached.dll exist?). We want to switch from storing sessions in MySQL to memcached. Switching to a unified Linux environment is not an option due to specialized software that we need on our Windows machines.

Community
  • 1
  • 1
Mike Todd
  • 7,227
  • 2
  • 15
  • 11
  • They're not compatible. The protocol is simple and we'll documented, its easy to write your own native PHP client or use one of the many examples available on the internet, e.g. https://github.com/clickalicious/Memcached.php but why go to all this pain for a workaround if your mysql solution works? – symcbean Dec 10 '15 at 23:23
  • @symcbean Mainly because storing sessions in MySQL is a lot of unnecessary overhead. That alone accounts for about 13% of our database load because the sessions table is so "hot." But yeah, looks like we might have to go with an alternative like Couchbase or Redis. – Mike Todd Dec 11 '15 at 03:37
  • Are you using handler syntax? The MyISAM or MEMORY storage engine? – symcbean Dec 11 '15 at 10:39
  • We are using InnoDB and since that has row-level locking (and there generally won't be contention for the same session), we aren't using handler syntax. We could use MEMORY storage engine as a workaround and preclude the need for memcached or couchbase, I suppose. – Mike Todd Dec 11 '15 at 16:53

0 Answers0