awslabs / aws-elasticache-cluster-client-memcached-for-php

Amazon ElastiCache Cluster Client is an enhanced PHP library to connect to ElastiCache clusters. This client library has been built upon libmemcached and is released under the Apache License.
Other
62 stars 33 forks source link

[question] Also usable with regular Memcached server? #37

Open heidemn opened 3 years ago

heidemn commented 3 years ago

Hi,

We have an application that we offer both on AWS and on-premises. My question is, is it possible + advisable to use the Elasticache client with regular Memcached servers (for on-premises)? = Is there any reason not to do so? The advantage would be that we could build a single Docker image for both use cases.

I'm assuming it could possibly work like this, can you confirm?

Usage with Elasticache + autodiscovery:

$dynamic_client = new Memcached('persistent-id');
$dynamic_client->setOption(Memcached::OPT_CLIENT_MODE, Memcached::DYNAMIC_CLIENT_MODE);
$dynamic_client->addServer("mycluster.abcdef.cfg.use1.cache.amazonaws.com", 11211);

Usage with regular Memcached, on-premises:

$static_client = new Memcached('persistent-id');
$static_client->setOption(Memcached::OPT_CLIENT_MODE, Memcached::STATIC_CLIENT_MODE);
$static_client->addServer("memcached-container", 11211);

And, another question: Have you guys considered contributing your changes upstream to https://github.com/php-memcached-dev/php-memcached and https://github.com/libmemcached/libmemcached ? I guess this would reduce the overhead and delay for you to support new PHP versions. And for the users, it would simplify the installation, since the OS package manager can be used to install the client.