示例#1
0
文件: ext_memcache.cpp 项目: 2bj/hhvm
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;
}
示例#2
0
文件: ext_memcache.cpp 项目: 2bj/hhvm
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;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
0
 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));
 }
示例#6
0
文件: ext_memcache.cpp 项目: 2bj/hhvm
 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));
 }
示例#7
0
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);
  }
}
示例#8
0
static std::string ini_get_hash_function(void *p) {
  return MEMCACHEG(hash_strategy);
}