static bool ini_on_update_hash_function(const std::string& value) { if (!strncasecmp(value.data(), "crc32", sizeof("crc32"))) { MEMCACHEG(hash_strategy) = "crc32"; } else if (!strncasecmp(value.data(), "fnv", sizeof("fnv"))) { MEMCACHEG(hash_strategy) = "fnv"; } return false; }
static bool ini_on_update_hash_strategy(const std::string& value) { if (!strncasecmp(value.data(), "standard", sizeof("standard"))) { MEMCACHEG(hash_strategy) = "standard"; } else if (!strncasecmp(value.data(), "consistent", sizeof("consistent"))) { MEMCACHEG(hash_strategy) = "consistent"; } return false; }
bool ini_on_update_hash_function(CStrRef value, void *p) { if (!strncasecmp(value.data(), "crc32", sizeof("crc32"))) { MEMCACHEG(hash_strategy) = "crc32"; } else if (!strncasecmp(value.data(), "fnv", sizeof("fnv"))) { MEMCACHEG(hash_strategy) = "fnv"; } else { return false; } return true; }
bool ini_on_update_hash_strategy(CStrRef value, void *p) { if (!strncasecmp(value.data(), "standard", sizeof("standard"))) { MEMCACHEG(hash_strategy) = "standard"; } else if (!strncasecmp(value.data(), "standard", sizeof("consistent"))) { MEMCACHEG(hash_strategy) = "consistent"; } else { return false; } return true; }
void requestInit() override { IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "memcache.hash_strategy", "standard", ini_on_update_hash_strategy, ini_get_hash_strategy, &MEMCACHEG(hash_strategy)); IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "memcache.hash_function", "crc32", ini_on_update_hash_function, ini_get_hash_function, &MEMCACHEG(hash_function)); }
void threadInit() override { IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "memcache.hash_strategy", "standard", IniSetting::SetAndGet<std::string>( ini_on_update_hash_strategy, nullptr ), &MEMCACHEG(hash_strategy)); IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "memcache.hash_function", "crc32", IniSetting::SetAndGet<std::string>( ini_on_update_hash_function, nullptr ), &MEMCACHEG(hash_function)); }
c_Memcache::c_Memcache(Class* cb) : ExtObjectData(cb), m_memcache(), m_compress_threshold(0), m_min_compress_savings(0.2) { memcached_create(&m_memcache); if (MEMCACHEG(hash_strategy) == "consistent") { // need to hook up a global variable to set this memcached_behavior_set(&m_memcache, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA); } else { memcached_behavior_set(&m_memcache, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_MODULA); } if (MEMCACHEG(hash_function) == "fnv") { memcached_behavior_set(&m_memcache, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_FNV1A_32); } else { memcached_behavior_set(&m_memcache, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_CRC); } }
static std::string ini_get_hash_function(void *p) { return MEMCACHEG(hash_strategy); }