Skip to content

Instantly share code, notes, and snippets.

@adsr
Created December 10, 2014 20:23
Show Gist options
  • Save adsr/9caf91b22a38d6b69a00 to your computer and use it in GitHub Desktop.
Save adsr/9caf91b22a38d6b69a00 to your computer and use it in GitHub Desktop.
diff --git a/hphp/runtime/ext/memcached/ext_memcached.cpp b/hphp/runtime/ext/memcached/ext_memcached.cpp
index 4300861..ecfa56d 100644
--- a/hphp/runtime/ext/memcached/ext_memcached.cpp
+++ b/hphp/runtime/ext/memcached/ext_memcached.cpp
@@ -86,22 +86,24 @@ const int64_t q_Memcached$$HASH_HSIEH
const int64_t q_Memcached$$HASH_MURMUR
= MEMCACHED_HASH_MURMUR;
const int64_t q_Memcached$$OPT_DISTRIBUTION
= MEMCACHED_BEHAVIOR_DISTRIBUTION;
const int64_t q_Memcached$$DISTRIBUTION_MODULA
= MEMCACHED_DISTRIBUTION_MODULA;
const int64_t q_Memcached$$DISTRIBUTION_CONSISTENT
= MEMCACHED_DISTRIBUTION_CONSISTENT;
const int64_t q_Memcached$$DISTRIBUTION_CONSISTENT_KETAMA
= MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA;
+#ifdef MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED
const int64_t q_Memcached$$DISTRIBUTION_CONSISTENT_WEIGHTED
= MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED;
+#endif
const int64_t q_Memcached$$OPT_LIBKETAMA_COMPATIBLE
= MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED;
const int64_t q_Memcached$$OPT_BUFFER_WRITES
= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS;
const int64_t q_Memcached$$OPT_BINARY_PROTOCOL
= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL;
const int64_t q_Memcached$$OPT_NO_BLOCK
= MEMCACHED_BEHAVIOR_NO_BLOCK;
const int64_t q_Memcached$$OPT_TCP_NODELAY
= MEMCACHED_BEHAVIOR_TCP_NODELAY;
@@ -1201,21 +1203,23 @@ String HHVM_METHOD(Memcached, getresultmessage) {
}
}
///////////////////////////////////////////////////////////////////////////////
IMPLEMENT_THREAD_LOCAL(MemcachedData::ImplMap, MemcachedData::s_persistentMap);
const StaticString s_Memcached("Memcached");
const StaticString s_DISTRIBUTION_CONSISTENT("DISTRIBUTION_CONSISTENT");
const StaticString s_DISTRIBUTION_CONSISTENT_KETAMA("DISTRIBUTION_CONSISTENT_KETAMA");
+#ifdef MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED
const StaticString s_DISTRIBUTION_CONSISTENT_WEIGHTED("DISTRIBUTION_CONSISTENT_WEIGHTED");
+#endif
const StaticString s_DISTRIBUTION_MODULA("DISTRIBUTION_MODULA");
const StaticString s_GET_PRESERVE_ORDER("GET_PRESERVE_ORDER");
const StaticString s_HASH_CRC("HASH_CRC");
const StaticString s_HASH_DEFAULT("HASH_DEFAULT");
const StaticString s_HASH_FNV1_32("HASH_FNV1_32");
const StaticString s_HASH_FNV1_64("HASH_FNV1_64");
const StaticString s_HASH_FNV1A_32("HASH_FNV1A_32");
const StaticString s_HASH_FNV1A_64("HASH_FNV1A_64");
const StaticString s_HASH_HSIEH("HASH_HSIEH");
const StaticString s_HASH_MD5("HASH_MD5");
@@ -1325,24 +1329,26 @@ class MemcachedExtension : public Extension {
);
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_DISTRIBUTION_CONSISTENT.get(),
q_Memcached$$DISTRIBUTION_CONSISTENT
);
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_DISTRIBUTION_CONSISTENT_KETAMA.get(),
q_Memcached$$DISTRIBUTION_CONSISTENT_KETAMA
);
+#ifdef MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_DISTRIBUTION_CONSISTENT_WEIGHTED.get(),
q_Memcached$$DISTRIBUTION_CONSISTENT_WEIGHTED
);
+#endif
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_DISTRIBUTION_MODULA.get(),
q_Memcached$$DISTRIBUTION_MODULA
);
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_GET_PRESERVE_ORDER.get(),
q_Memcached$$GET_PRESERVE_ORDER
);
Native::registerClassConstant<KindOfInt64>(
s_Memcached.get(), s_HASH_CRC.get(), q_Memcached$$HASH_CRC
diff --git a/hphp/test/slow/ext_memcached/ketama_opt.php.skipif b/hphp/test/slow/ext_memcached/ketama_opt.php.skipif
new file mode 100644
index 0000000..e3b27f7
--- /dev/null
+++ b/hphp/test/slow/ext_memcached/ketama_opt.php.skipif
@@ -0,0 +1,7 @@
+<?php
+
+$memc = new Memcached();
+$refl = new ReflectionClass($memc);
+if ($refl->getConstant('DISTRIBUTION_CONSISTENT_WEIGHTED') === false) {
+ echo "SKIP Memcached::DISTRIBUTION_CONSISTENT_WEIGHTED not defined";
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment