2

awsでElasticacheクラスターを使用しています。詳細は

Engine: Memcached
Cache Engine Version: 1.4.5

node に telnet を実行すると、node ip-port を使用して memcached サーバーに常にアクセスできます。しかし、PHP に接続しようとすると、memcache オブジェクトがまったく作成されないことがあります。

クライアントは、接続に php-pecl-memcache-3.0.5を使用します。

使用されているコードは次のとおりです

$cache = memcache_connect(MEMCACHE_HOST, MEMCACHE_PORT);

$cacheオブジェクトが作成されないことがあります。

問題を解決する方法を教えてください。ありがとう。

4

2 に答える 2

1

現在、更新されたバージョンの memcached (現在は 1.4.14) を使用しており、接続の問題は memcache の 1.4.5 バージョンのバグの結果である可能性があると考えています。

于 2013-06-01T16:09:03.450 に答える
1

これを試して:

<?php

$server_endpoint = "xxx.xx.xfg.sae1.cache.amazonaws.com";
$server_port = 11211;

if (version_compare(PHP_VERSION, '5.4.0') < 0) {
    //PHP 5.3 with php-pecl-memcache
    $client = new Memcache;
    $client->connect($server_endpoint, $server_port);
    //If you need debug see $client->getExtendedStats();
    $client->set('myKey', 'My Value PHP 5.3');
} else {
    //PHP 5.4 with php54-pecl-memcached:
    $client = new Memcached;
    $client->addServer($server_endpoint, $server_port);
    $client->set('myKey', 'My Value PHP 5.4');
}

echo 'Data in the cluster: [' . $client->get('myKey') . ']';
于 2013-08-16T20:36:58.940 に答える