After installing memcache on my EC2 Linux instance using this:
:~$ sudo apt-get install memcached php5-memcache
I can immediately do this:
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$array_result=$this->db->query("SELECT * where ...."); // some DB query
$memcache->set('my_items', $array_result, false, 60*60*24);
and later can access this cached array like this:
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$my_items=$memcache->get('my_items');
var_dump($my_items);
My question is what is the Elasticache syntax that correlates with memcache’s connect(), set(), and get() commands? I’m totally confused by the Elasticache part of the AWS PHP SDK.
You need to create elasticache node (AWS Management Console), to which you can connect via memcache client, take a look at the Getting started guide.
If you want to control your cache nodes with your code then you should use Elasticache SDK.
You don’t need memcache server on your EC2 Linux instance it’s enough to have php5-memcache PECL extension.