コード例 #1
0
ファイル: link_mining.c プロジェクト: easingz/BigHead
static memcached_pool_st* init_mq_pool(const char *addr, int max_pool)
{
    memcached_st *mq = create_memcacheq_from_str(addr);
    if (!mq)
    {
	printf("%s:%d create send pool error\n", __FILE__, __LINE__);
	exit(-1);
    }
    return memcached_pool_create(mq, max_pool, max_pool + 5);
}
コード例 #2
0
ファイル: arcus.cpp プロジェクト: jam2in/arcus-misc
    connection_pool::connection_pool(std::string admin, std::string service_code, int32_t initial, int32_t max, uint64_t timeout)
    : _admin(admin), _service_code(service_code), _initial(initial), _max(max), _timeout(timeout)
    {
        _master_handle = memcached_create(NULL);
        memcached_behavior_set(_master_handle, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
        _pool = memcached_pool_create(_master_handle, initial, max); 

        if (_pool == NULL) {
            std::cout << "memcached_pool_create() failed" << std::endl;
            return;
        }

        arcus_return_t rc = arcus_pool_connect(_pool, admin.c_str(), service_code.c_str());

        if (rc != ARCUS_SUCCESS) {
            std::cout << "arcus_pool_connect() failed" << std::endl;
            destroy();
        }

        std::stringstream stream;
        stream << "arcus::connection_pool[admin=" << _admin << ", service_code=" << _service_code << ", initial=" << _initial << ", max=" << _max << ", timeout=" << _timeout << "ms]";
        _str = stream.str();
    }