0

I can get .set() to work when interacting with Elasticache if I use the compression & time settings (third and forth settings)

 $memcached = new Memcached();
 $memcached->setOption(Memcached::OPT_CLIENT_MODE, Memcached::DYNAMIC_CLIENT_MODE);
 $memcached->addServer('goneglobalcache-1a.expalp.cfg.apse1.cache.amazonaws.com', 11211);
 $memcached->set('key', 'value', 60);

 $memcached->set('tester', 'set tester...', 0, 600);
 echo $memcached->get('tester');

If I remove the last 2 elements of the set() it does work eg:

 $memcached->set('tester', 'set tester...');
 echo $memcached->get('tester');

This is the first time I've used memcached/elasticache - would there be any reason why this would fail. Note: add() works as well so long as I only use the key/value parts and not the compression/time parts.

any advice?

thx

Adam
  • 19,932
  • 36
  • 124
  • 207

1 Answers1

1
public bool Memcached::set ( string $key , mixed $value [, int $expiration ] )

There is no compression flag in the set method, it's in Memcache not Memcached.

$memcached->set('tester', 'set tester...', 600);
epicdev
  • 922
  • 4
  • 10
  • I thought I needed to be using memcached as it was newer and better? Is there a way to change this or is aws elasticache based on Memcache and not memcached? – Adam Jan 27 '13 at 10:01
  • Memcached and Memcache are both PHP extensions to work with memcache servers, so you can choose any of these two. Memcached has a bit more functionnalities than Memcache. http://php.net/manual/fr/class.memcached.php http://php.net/manual/fr/book.memcache.php So yes memcached is a good choice. – epicdev Jan 27 '13 at 10:03