すべてのプロダクト
Search
ドキュメントセンター

:ApsaraDB for Memcache でのPHP

最終更新日:Mar 20, 2020

ApsaraDB for Memcache での PHP 接続エラーのトラブルシューティング

1. ApsaraDB for Memcache の IP アドレスを Ping して、アドレスを正しく通達できるかどうかを確認します。
2. Telnet ApsaraDB for Memcache ポート11211にアクセス可能かどうかを確認します。
3. 次のコードをコピーし、システムに挿入して実行します。

$connect = new Memcached; //Declare a new memcached connection.
$connect->setOption(Memcached::OPT_COMPRESSION, false); //Turn off the compression function.
$connect->setOption(Memcached::OPT_BINARY_PROTOCOL, true); //Use the binary protocol.
$connect->addServer('aaaaaaaaaa.m.yyyyyyyyyyy.ocs.aliyuncs.com', 11211); //Add the address and port number of an OCS instance.
$connect->setSaslAuthData('aaaaaaaaaa, 'password'); //Set the OCS account and password for authentication. If the password-free function has been enabled, this step can be skipped.
$connect->set("hello", "world");
echo 'hello: ',$connect->get("hello");
$connect->quit();
?>


例:


php memtest.php


“hello world”が出力された場合は、ApsaraDB for Memcache の接続が正常であることを意味します。以下の図を参照してください。

memtest.png