Skip to content

Commit 2bd884f

Browse files
committed
Auto Discovery support for Amazon ElastiCache
1 parent 6ace07d commit 2bd884f

File tree

5 files changed

+127
-4
lines changed

5 files changed

+127
-4
lines changed

INSTALL

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To compile this package to generate the PHP memcached extension, do the following set of steps:
2+
3+
1) Checkout and compile the dependency package aws-elasticache-cluster-client-libmemcached via https://github.com/awslabs/aws-elasticache-cluster-client-libmemcached
4+
5+
2) Run the following set of commands under the current directory:
6+
7+
phpize
8+
./configure --with-libmemcached-dir=<path to libmemcached build directory>
9+
make
10+
make install

LICENSE

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,93 @@
1+
--------------------------------------------------------------------------------------------
2+
The Amazon Elastic Cache Cluster Client is based on the software packages licensed under the
3+
PHP License and other open source licenses. All modifications to these software packages are
4+
copyright 2012-2013 Amazon.com, inc. or its affiliates. All Rights Reserved.
5+
--------------------------------------------------------------------------------------------
6+
7+
Appendix A
8+
Amazon Software License
9+
http://aws.amazon.com/asl/
10+
11+
This Amazon Software License ("License") governs your use, reproduction, and distribution of the accompanying
12+
software as specified below.
13+
14+
1. Definitions
15+
16+
"Licensor" means any person or entity that distributes its Work.
17+
18+
"Software" means the original work of authorship made available under this License.
19+
20+
"Work" means the Software and any additions to or derivative works of the Software that are made available
21+
under this License.
22+
23+
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the meaning as provided
24+
under U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall
25+
not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work.
26+
27+
Works, including the Software, are "made available" under this License by including in or with the Work either
28+
(a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License.
29+
30+
2. License Grants
31+
32+
2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a
33+
perpetual, worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works
34+
of, publicly display, publicly perform, sublicense and distribute its Work and any resulting derivative works
35+
in any form.
36+
37+
2.2 Patent Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual,
38+
worldwide, non-exclusive, royalty-free patent license to make, have made, use, sell, offer for sale, import,
39+
and otherwise transfer its Work, in whole or in part. The foregoing license applies only to the patent claims
40+
licensable by Licensor that would be infringed by Licensor's Work (or portion thereof) individually and
41+
excluding any combinations with any other materials or technology.
42+
43+
3. Limitations
44+
45+
3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you
46+
include a complete copy of this License with your distribution, and (c) you retain without modification any
47+
copyright, patent, trademark, or attribution notices that are present in the Work.
48+
49+
3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and
50+
distribution of your derivative works of the Work ("Your Terms") only if (a) Your Terms provide that the use
51+
limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative
52+
works that are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution
53+
requirements in Section 3.1) will continue to apply to the Work itself.
54+
55+
3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use with the web
56+
services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon
57+
Web Services LLC.
58+
59+
3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim,
60+
cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work,
61+
then your rights under this License from such Licensor (including the grants in Sections 2.1 and 2.2) will
62+
terminate immediately.
63+
64+
3.5 Trademarks. This License does not grant any rights to use any Licensor's or its affiliates' names, logos, or
65+
trademarks, except as necessary to reproduce the notices described in this License.
66+
67+
3.6 Termination. If you violate any term of this License, then your rights under this License (including the
68+
grants in Sections 2.1 and 2.2) will terminate immediately.
69+
70+
4. Disclaimer of Warranty.
71+
72+
THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
73+
WARRANTIES OR CONDITIONS OF M ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU
74+
BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. SOME STATES' CONSUMER LAWS DO NOT ALLOW EXCLUSION
75+
OF AN IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
76+
77+
5. Limitation of Liability.
78+
79+
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING
80+
NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
81+
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR
82+
INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR
83+
DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN
84+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
85+
86+
Effective Date - April 18, 2008 Copyright 2008 Amazon.com, Inc. or its affiliates. All rights reserved.
87+
88+
89+
Appendix B
90+
191
--------------------------------------------------------------------
292
The PHP License, version 3.01
393
Copyright (c) 1999 - 2010 The PHP Group. All rights reserved.
@@ -66,3 +156,4 @@ please see <http://www.php.net>.
66156

67157
PHP includes the Zend Engine, freely available at
68158
<http://www.zend.com>.
159+

README.markdown

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Build Status
44

55
Description
66
-----------
7-
This extension uses libmemcached library to provide API for communicating with
8-
memcached servers.
7+
This extension uses Amazon ElastiCache fork of libmemcached library to provide API
8+
for communicating with ElastiCache servers. Our changes are based on open-source
9+
memcached extension v.2.1.0 from https://github.com/php-memcached-dev/php-memcached
910

10-
memcached is a high-performance, distributed memory object caching system,
11+
Amazon ElastiCache is a high-performance, distributed memory object caching system,
1112
generic in nature, but intended for use in speeding up dynamic web applications
1213
by alleviating database load.
1314

@@ -23,4 +24,6 @@ Resources
2324
---------
2425
* [libmemcached](http://libmemcached.org/libMemcached.html)
2526
* [memcached](http://memcached.org/)
27+
* [AmazonElastiCache Auto Discovery](http://docs.amazonwebservices.com/AmazonElastiCache/latest/UserGuide/AutoDiscovery.html)
28+
* [php-memcached] (https://github.com/php-memcached-dev/php-memcached)
2629
* [igbinary](https://github.com/phadej/igbinary/)

memcached-api.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ class Memcached {
7979

8080
const OPT_RANDOMIZE_REPLICA_READS;
8181

82+
const OPT_CLIENT_MODE;
83+
84+
const OPT_DYNAMIC_POLLING_INTERVAL_SECS;
85+
86+
/**
87+
* Client mode parameters
88+
*/
89+
const STATIC_CLIENT_MODE;
90+
91+
const DYNAMIC_CLIENT_MODE;
8292

8393
/**
8494
* Class parameters
@@ -186,6 +196,7 @@ class Memcached {
186196

187197
const RES_CONNECTION_SOCKET_CREATE_FAILURE;
188198

199+
const RES_MEMCACHED_NO_CONFIG_SERVER;
189200

190201
public function __construct( $persistent_id = '', $on_new_object_cb = null ) {}
191202

php_memcached.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4228,6 +4228,8 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
42284228
* libmemcached behavior options
42294229
*/
42304230

4231+
REGISTER_MEMC_CLASS_CONST_LONG(OPT_CLIENT_MODE, MEMCACHED_BEHAVIOR_CLIENT_MODE);
4232+
REGISTER_MEMC_CLASS_CONST_LONG(OPT_DYNAMIC_POLLING_INTERVAL_SECS, MEMCACHED_BEHAVIOR_DYNAMIC_POLLING_THRESHOLD_SECS);
42314233
REGISTER_MEMC_CLASS_CONST_LONG(OPT_HASH, MEMCACHED_BEHAVIOR_HASH);
42324234
REGISTER_MEMC_CLASS_CONST_LONG(HASH_DEFAULT, MEMCACHED_HASH_DEFAULT);
42334235
REGISTER_MEMC_CLASS_CONST_LONG(HASH_MD5, MEMCACHED_HASH_MD5);
@@ -4314,10 +4316,10 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
43144316
REGISTER_MEMC_CLASS_CONST_LONG(RES_INVALID_HOST_PROTOCOL, MEMCACHED_INVALID_HOST_PROTOCOL);
43154317
REGISTER_MEMC_CLASS_CONST_LONG(RES_MEMORY_ALLOCATION_FAILURE, MEMCACHED_MEMORY_ALLOCATION_FAILURE);
43164318
REGISTER_MEMC_CLASS_CONST_LONG(RES_CONNECTION_SOCKET_CREATE_FAILURE, MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE);
4317-
43184319
REGISTER_MEMC_CLASS_CONST_LONG(RES_E2BIG, MEMCACHED_E2BIG);
43194320
REGISTER_MEMC_CLASS_CONST_LONG(RES_KEY_TOO_BIG, MEMCACHED_KEY_TOO_BIG);
43204321
REGISTER_MEMC_CLASS_CONST_LONG(RES_SERVER_TEMPORARILY_DISABLED, MEMCACHED_SERVER_TEMPORARILY_DISABLED);
4322+
REGISTER_MEMC_CLASS_CONST_LONG(RES_MEMCACHED_NO_CONFIG_SERVER, MEMCACHED_NO_CONFIG_SERVER);
43214323

43224324
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x01000008
43234325
REGISTER_MEMC_CLASS_CONST_LONG(RES_SERVER_MEMORY_ALLOCATION_FAILURE, MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE);
@@ -4335,6 +4337,12 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
43354337

43364338
REGISTER_MEMC_CLASS_CONST_LONG(RES_PAYLOAD_FAILURE, MEMC_RES_PAYLOAD_FAILURE);
43374339

4340+
/**
4341+
* Client mode types
4342+
*/
4343+
REGISTER_MEMC_CLASS_CONST_LONG(STATIC_CLIENT_MODE, STATIC_MODE);
4344+
REGISTER_MEMC_CLASS_CONST_LONG(DYNAMIC_CLIENT_MODE, DYNAMIC_MODE);
4345+
43384346
/*
43394347
* Serializer types.
43404348
*/

0 commit comments

Comments
 (0)