문제

I'm using the following code to connect to Elasticache and have installed php-memcached and added /etc/php.d/memcached.ini - the connect doesn't error and seems to work:

  $server_endpoint = "etc-etc-etc.expalp.cfg.apse1.cache.amazonaws.com";
  $server_port = 11211;
  $dynamic_client = new Memcached();
  $dynamic_client->setOption(Memcached::OPT_CLIENT_MODE, Memcached::DYNAMIC_CLIENT_MODE);
  $dynamic_client->addServer($server_endpoint, $server_port);
  $dynamic_client->set('key', 'value', 60);

I have 2 questions:

  1. How do I know if Consistant Hashing is enabled - I've read about its importance but don't know how to enable it or check its enabled.

  2. Is there a way a can see what is written to Elasticache? I'm new to this and I would like to be able to confirm data is being written to the cache.

thank you

도움이 되었습니까?

해결책 2

  1. Its handled by an ini setting More in the manual
  2. I suppose the best way is to use the memcached client tools. Or just do a test, do you get back what you write?

다른 팁

Try this:

<?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') . ']';
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top