- Its handled by an ini setting More in the manual
- I suppose the best way is to use the memcached client tools. Or just do a test, do you get back what you write?
PHP + Connect to Amazon ElastiCache
-
05-03-2022 - |
문제
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:
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.
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
다른 팁
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') . ']';
제휴하지 않습니다 StackOverflow