• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ freeReplyObject函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中freeReplyObject函数的典型用法代码示例。如果您正苦于以下问题:C++ freeReplyObject函数的具体用法?C++ freeReplyObject怎么用?C++ freeReplyObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了freeReplyObject函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_range_long

int test_range_long(int frompos, int slen, int count)
{
	int		fd;	
	int		endpos = frompos + slen;
	struct timeval start, end;
	redisReply *ret;

	ret = redisConnect(&fd, "127.0.0.1", 6379);
	if (NULL != ret) {
		DINFO("connect error! %s\n", ret->reply);
		return -1;
	}
	int  i;
	char *key = "haha";
	char val[32];
	char buf[128];

	gettimeofday(&start, NULL);	
	for (i = 0; i < count; i++) {
		sprintf(buf, "LRANGE %s %d %d", key, frompos, endpos - 1);
		//ret = redisCommand(fd, "LRANGE %s %d %d", key, frompos, slen);
		ret = redisCommand(fd, buf);
		if (ret->type != REDIS_REPLY_ARRAY) {
			DINFO("lrange error! %d, %s\n", ret->type, ret->reply);
			return -2;
		}
		if (ret->elements != slen) {
			DERROR("lrange count error: %d, len:%d\n", ret->elements, slen);
		}
		freeReplyObject(ret);
	}
	gettimeofday(&end, NULL);	

	unsigned int tmd = timediff(&start, &end);
	double speed = ((double)count / tmd) * 1000000;
	DINFO("range long use time: %u, speed: %.2f\n", tmd, speed);
	
	close(fd);
	return (int)speed;
}
开发者ID:cygsxak,项目名称:memlink,代码行数:40,代码来源:testredis.c


示例2: _do_redis_command

long long _do_redis_command( const char ** args,const size_t * argvlen, size_t arg_count) {

    pthread_mutex_lock(&sredisContext_mutex);

    redisContext *c = NULL;
    redisReply *reply;


    c = (redisContext*)_redis_context_init();
    if (!c) {
	info_print("_redis_context_init return null, connect failed\n");
	pthread_mutex_unlock(&sredisContext_mutex);
	return -1;
    }

    debug_print("%s %s %s\n",args[0] ,args[1],args[2]);

    reply =  redisCommandArgv(c,arg_count,args,argvlen);
    if(!reply) {

    	c = (redisContext*)_redis_context_reinit();
        if (!c) {
            info_print("_do_redis_command, Cannot reconnect to redis\n ");
            pthread_mutex_unlock(&sredisContext_mutex);
            return -1;
        }
    	reply = redisCommandArgv(c,arg_count,args,argvlen);
        if (!reply) {
            info_print("_do_redis_command, reconnect to redis and re-execute redisCommandArgv failed\n ");
            pthread_mutex_unlock(&sredisContext_mutex);
            return -1;
        }
    }

	if(reply) {
	    freeReplyObject(reply);
	}
	pthread_mutex_unlock(&sredisContext_mutex);
    return 0;
}
开发者ID:AALEKH,项目名称:mysql2redis,代码行数:40,代码来源:lib_mysqludf_redis.c


示例3: hashes

//-------------------------------------------------------------------------------------
bool KBEEntityLogTableRedis::queryEntity(DBInterface * dbi, DBID dbid, EntityLog& entitylog, ENTITY_SCRIPT_UID entityType)
{
	/*
	kbe_entitylog:dbid:entityType = hashes(entityID, ip, port, componentID)
	*/
	redisReply* pRedisReply = NULL;

	try
	{
		static_cast<DBInterfaceRedis*>(dbi)->query(fmt::format("HMGET kbe_entitylog:{}:{} entityID ip port componentID",
			dbid, entityType), &pRedisReply, false);
	}
	catch(...)
	{
	}

	entitylog.dbid = dbid;
	entitylog.componentID = 0;
	entitylog.entityID = 0;
	entitylog.ip[0] = '\0';
	entitylog.port = 0;

	if(pRedisReply)
	{
		if(pRedisReply->type == REDIS_REPLY_ARRAY)
		{
			if(RedisHelper::check_array_results(pRedisReply))
			{
				StringConv::str2value(entitylog.entityID, pRedisReply->element[0]->str);
				kbe_snprintf(entitylog.ip, MAX_IP, "%s", pRedisReply->element[1]->str);
				StringConv::str2value(entitylog.port, pRedisReply->element[2]->str);
				StringConv::str2value(entitylog.componentID, pRedisReply->element[3]->str);
			}
		}
		
		freeReplyObject(pRedisReply); 
	}

	return entitylog.componentID > 0;
}
开发者ID:wandison,项目名称:kbengine,代码行数:41,代码来源:kbe_table_redis.cpp


示例4: redis_pull

int redis_pull(char *redisqueuename, void *buf, 
		int maxload, size_t obj_size, int *numloaded, const char* cmd)
{
	assert(rctx);
	long elems_in_redis = redis_get_sizeof_list(redisqueuename);
	long num_to_add = MIN(elems_in_redis, maxload);
	log_info("redis", "INFO: redis load called on %s. Transfering %li "
			"of %li elements to in-memory queue.",
			redisqueuename,
			num_to_add, elems_in_redis);
	for(int i=0; i < num_to_add; i++) {
		redisAppendCommand(rctx, "%s %s", cmd, redisqueuename);
	}
	for(int i=0; i < num_to_add; i++) {
		redisReply *reply;
		int rc = redisGetReply(rctx, (void**) &reply);
		if (rc != REDIS_OK) {
			log_fatal("redis", "response from redis != REDIS_OK");
			return -1;
		}
		if (!reply) {
			log_fatal("redis", "no reply provided by redis.");
			return -1;
		}
		if (reply->type != REDIS_REPLY_STRING) {
			log_fatal("redis", 
					"unxpected reply type from redis.");
			return -1;
		}
		if ((size_t)reply->len != obj_size) {
			log_fatal("redis", "ERROR: unexpected lengthed "
					"object provided by redis.\n");
			return -1;
		}
		memcpy((void*)((intptr_t)buf+i*obj_size), reply->str, obj_size);
		freeReplyObject(reply);
	}
	*numloaded = num_to_add;
	return 0;
}
开发者ID:zakird,项目名称:zdlibc,代码行数:40,代码来源:redis.c


示例5: lrange

    // redis lrange: get list from start to end -- with R serialization
    Rcpp::List lrange(std::string key, int start, int end) {

        // uses binary protocol, see hiredis doc at github
        redisReply *reply = 
            static_cast<redisReply*>(redisCommand(prc_, "LRANGE %s %d %d", 
                                                  key.c_str(), start, end));

        unsigned int len = reply->elements;
        //Rcpp::Rcout << "Seeing " << len << " elements\n";
        Rcpp::List x(len);
        for (unsigned int i = 0; i < len; i++) {
            //Rcpp::Rcout << "  Seeing size " << reply->element[i]->len << "\n";
            int nc = reply->element[i]->len;
            Rcpp::RawVector res(nc);
            memcpy(res.begin(), reply->element[i]->str, nc);
            SEXP obj = unserializeFromRaw(res);
            x[i] = obj;
        }
                                               
        freeReplyObject(reply);
        return(x);
    }
开发者ID:agstudy,项目名称:rhiredis,代码行数:23,代码来源:Redis.cpp


示例6: main

int main()
{
    struct timeval timeout = {2, 0};
    redisContext *pRedisContext = (redisContext*)redisConnectWithTimeout("127.0.0.1", 6379, timeout);
    if((pRedisContext == NULL) || (pRedisContext->err))
    {
        if(pRedisContext)
        {
            std::cout << "connect error:" << pRedisContext->errstr << std::endl; 
        }else{
            std::cout << "connect error: can't allocate redis context" << std::endl;
        }
        return -1;
    }

    redisReply *pRedisReply = (redisReply*)redisCommand(pRedisContext, "INFO");
    std::cout << pRedisReply->str << std::endl;

    freeReplyObject(pRedisReply);
    
    return 0;
}
开发者ID:aichixihongshi,项目名称:CloudBackup,代码行数:22,代码来源:testRedis.cpp


示例7: main

int main(int argc, char *argv[]) {
    unsigned int j;
    redisContext *c;
    redisReply *reply;

    struct timeval timeout = { 1, 500000 }; // 1.5 seconds
    c = redisConnectWithTimeout((char*)"127.0.0.2", 6379, timeout);
    if (c->err) {
        printf("Connection error: %s\n", c->errstr);
        exit(1);
    }


    for (int i=0; i < sizeof(testStrings)/sizeof(char*); i++) {
        double score = atof_raw(testStrings[i]);
        reply = redisCommand(c, "ZADD %s %.20e %s", "ascii|test", score, testStrings[i]);
        printf("result: %s\n", reply->str);
        freeReplyObject(reply);
    }
    
    return 0;
}
开发者ID:trentonstrong,项目名称:ascii_to_float,代码行数:22,代码来源:main.c


示例8: PROXY_NOTUSED

void *sumIntegerKeyProc(proxyContext *p, int argc, char **argv, redisKeyInfo *keyInfo){
    PROXY_NOTUSED(keyInfo);
    redisContext *c;
    redisReply *replyAll; 
    
    replyAll = createReplyObject(REDIS_REPLY_INTEGER);
    if( replyAll ){
        for( int i = 0; i < p->count; i++ ){
            redisReply *reply;
            c = getRedisContextWithIdx( p, i );
            reply = proxyCommandArgvList( p, c, argc, (const char **)argv );
            int value = 0;
            if( reply ) {
                value = reply->integer;
                freeReplyObject(reply);
            }
            
            replyAll->integer += value;
        }
    }
    return replyAll;
}
开发者ID:charsyam,项目名称:hiredis-proxy,代码行数:22,代码来源:proxy.c


示例9: mrb_redis_hkeys

mrb_value mrb_redis_hkeys(mrb_state *mrb, mrb_value self)
{
    mrb_value key, array = mrb_nil_value();
    redisContext *rc = DATA_PTR(self);

    mrb_get_args(mrb, "o", &key);
    const char *argv[] = {"HKEYS", RSTRING_PTR(key)};
    size_t lens[] = {5, RSTRING_LEN(key)};
    redisReply *rr = redisCommandArgv(rc, 2, argv, lens);
    if (rr->type == REDIS_REPLY_ARRAY) {
        if (rr->elements > 0) {
            int i;

            array = mrb_ary_new(mrb);
            for (i = 0; i < rr->elements; i++) {
                mrb_ary_push(mrb, array, mrb_str_new(mrb, rr->element[i]->str, rr->element[i]->len));
            }
        }
    }
    freeReplyObject(rr);
    return array;
}
开发者ID:hsbt,项目名称:mruby-redis,代码行数:22,代码来源:mrb_redis.c


示例10: readHandler

static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    client c = privdata;
    void *reply = NULL;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(fd);
    REDIS_NOTUSED(mask);

    /* Calculate latency only for the first read event. This means that the
     * server already sent the reply and we need to parse it. Parsing overhead
     * is not part of the latency, so calculate it only once, here. */
    if (c->latency < 0) c->latency = ustime()-(c->start);

    if (redisBufferRead(c->context) != REDIS_OK) {
        fprintf(stderr,"Error: %s\n",c->context->errstr);
        exit(1);
    } else {
        while(c->pending) {
            if (redisGetReply(c->context,&reply) != REDIS_OK) {
                fprintf(stderr,"Error: %s\n",c->context->errstr);
                exit(1);
            }
            if (reply != NULL) {
                if (reply == (void*)REDIS_REPLY_ERROR) {
                    fprintf(stderr,"Unexpected error reply, exiting...\n");
                    exit(1);
                }

                freeReplyObject(reply);

                if (config.requests_finished < config.requests)
                    config.latency[config.requests_finished++] = c->latency;
                c->pending--;
                if (c->pending == 0) clientDone(c);
            } else {
                break;
            }
        }
    }
}
开发者ID:newappfirst,项目名称:ssl-redis,代码行数:39,代码来源:redis-benchmark.c


示例11: keys

void keys(const char *pattern)
{
    int i;
    redisReply *reply;
    reply = redisCommand(ctx, "KEYS %s", pattern);
    if (reply == NULL)
    {
        log_error("keys fails: %s", ctx->errstr);
        // handle error
        return;
    }
    if (reply->type == REDIS_REPLY_ARRAY) {
        for (i = 0; i < reply->elements; i++) {
            log_debugv("%d) %s", i, reply->element[i]->str);
        }
    }
    else {
        log_warn("keys: unexpected reply type: %d", reply->type);
    }

    freeReplyObject(reply);
}
开发者ID:NeverMore93,项目名称:INTANG,代码行数:22,代码来源:redis.c


示例12: set_int_ex_nx

void set_int_ex_nx(const char *key, int val, int timeout)
{
    redisReply *reply;
    reply = redisCommand(ctx, "SET %s %d EX %d NX", key, val, timeout);
    if (reply == NULL)
    {
        log_error("set_int_ex_nx fails: %s", ctx->errstr);
        // handle error
        return;
    }
    if (reply->type == REDIS_REPLY_STATUS) {
        log_debugv("set_int_ex_nx %s %d %s", key, val, reply->str);
    }
    else if (reply->type == REDIS_REPLY_NIL) {
        log_debugv("set_int_ex_nx: %s exists", key);
    }
    else {
        log_warn("set_int_ex_nx: unexpected reply type: %d", reply->type);
    }

    freeReplyObject(reply);
}
开发者ID:NeverMore93,项目名称:INTANG,代码行数:22,代码来源:redis.c


示例13: add_one

int add_one(pyrebloomctxt *ctxt, const char *data, uint32_t data_size)
{
    uint32_t ct = 0, total = 0, count = 1;
    redisReply *reply = NULL;

    for (uint32_t i = 0; i < ctxt->hashes; ++i) {
        uint64_t hashed_data = hash(data, data_size, ctxt->seeds[i], ctxt->bits);
        redisAppendCommand(ctxt->ctxt, "SETBIT %s %lu 1",
            ctxt->keys[hashed_data / max_bits_per_key], hashed_data % max_bits_per_key);
    }

    for (uint32_t i = 0, ct = 0; i < ctxt->hashes; ++i) {
        /* Make sure that we were able to read a reply. Otherwise, provide
         * an error response */
        if (redisGetReply(ctxt->ctxt, (void**)(&reply)) == REDIS_ERR) {
            strncpy(ctxt->ctxt->errstr, "No pending replies", errstr_size);
            ctxt->ctxt->err = PYREBLOOM_ERROR;
            return PYREBLOOM_ERROR;
        }

        /* Consume and read the response */
        if (reply->type == REDIS_REPLY_ERROR) {
            ctxt->ctxt->err = PYREBLOOM_ERROR;
            strncpy(ctxt->ctxt->errstr, reply->str, errstr_size);
        } else {
            ct += reply->integer;
        }
        freeReplyObject(reply);
    }
    if (ct == ctxt->hashes) {
        total = 1;
    }

    if (ctxt->ctxt->err == PYREBLOOM_ERROR) {
        return PYREBLOOM_ERROR;
    }

    return count - total;
}
开发者ID:leovp,项目名称:pyreBloom-ng,代码行数:39,代码来源:bloom.c


示例14: hiredis_odb_backend__exists

int hiredis_odb_backend__exists(git_odb_backend *_backend, const git_oid *oid)
{
	hiredis_odb_backend *backend;
	int found;
	redisReply *reply;
	char *str_id = calloc(GIT_OID_HEXSZ + 1, sizeof(char));

	assert(_backend && oid);

	backend = (hiredis_odb_backend *) _backend;
	found = 0;

	git_oid_tostr(str_id, GIT_OID_HEXSZ, oid);

	reply = redisCommand(backend->db, "exists %s:%s:odb:%s", backend->prefix, backend->repo_path, str_id);
	if (reply->type == REDIS_REPLY_INTEGER)
		found = reply->integer;

	free(str_id);
	freeReplyObject(reply);
	return found;
}
开发者ID:ideal,项目名称:libgit2-backends,代码行数:22,代码来源:hiredis.c


示例15: ReConnect

bool Redis::Delete(string &key)
{
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "del %s", key.c_str());

    if (!reply){
        ReConnect();

        reply = (redisReply*)redisCommand(connect_, "del %s", key.c_str());
        if (!reply){
            _logger.error("delete key %s from redis error", key.c_str());
            return RESULT_ERROR;
        }
    }

    _logger.info("delete key %s from redis OK", key.c_str());
    freeReplyObject(reply);
    return RESULT_OK;
}
开发者ID:wenwuge,项目名称:EasyLib,代码行数:22,代码来源:redis.cpp


示例16: mapClient

static bool mapClient( disruptor* d, unsigned int id )
{
    assert( id < MAX_CONNECTIONS );
    if ( id >= MAX_CONNECTIONS )
        return false;

    unmapClient( d, id );

    {
        shmem* s;
        int64_t size;

        s = shmemOpen( 0, SHMEM_MUST_NOT_CREATE, "disruptor:%s:%d", d->address, id );
        if ( !s )
            return false;

        size = shmemGetSize( s );
        d->buffers[ id ].shmem = s;
        d->buffers[ id ].start = shmemGetPtr( s );
        d->buffers[ id ].end = ( d->buffers[ id ].start + size );
        d->buffers[ id ].tail = d->buffers[ id ].start;
        handleInfo( d, "for #%d: size=%u", id, (unsigned int)size );

        {
            redisContext* r = d->redis;
            redisReply* reply;

            reply = redisCommand( r, "GET disruptor:%s:%d:username", d->address, id );
            if ( reply->type == REDIS_REPLY_STRING )
                d->names[ id ] = strclone( reply->str );
            freeReplyObject( reply );
        }

        if ( !d->names[ id ] )
            return false;

        return true;
    }
}
开发者ID:shawnpresser,项目名称:disruption,代码行数:39,代码来源:disruptor.c


示例17: llpush

static int llpush(lua_State *L){
    if (!lua_isuserdata(L, 1) || !lua_isstring(L, 2) || !lua_isstring(L ,3)) {
        LOG_ERROR("arg error");
        return 0;
    }
    struct redisContext *c = lua_touserdata(L, 1);
    if (c == NULL) {
        LOG_ERROR("userdata is null");
        return 0;
    }
    const char *key = (const char *)lua_tostring(L, 2);
    size_t str_len;
    const char *str = (const char *)lua_tolstring(L, 3, &str_len);
    redisReply * reply = (redisReply *)redisCommand(c, "LPUSH %s %b", key, str, str_len);
    if (reply == NULL) {
        LOG_ERROR("lpush fail key:%s value:%s", key, str);
        return 0;
    }
    getCallback_push_reply(L, reply);
    freeReplyObject(reply);
    return 1;
}
开发者ID:zhangjinde,项目名称:lua333,代码行数:22,代码来源:lredis.c


示例18: ngx_http_dynamic_redirect_redis_connect

static redisContext*
ngx_http_dynamic_redirect_redis_connect(ngx_http_dynamic_redirect_loc_conf_t* conf)
{
    if (!conf->redis_context) {
        conf->redis_context = ngx_palloc(ngx_cycle->pool, sizeof(redis_connection));

        if (!conf->redis_context) {
            return NULL;
        }
        ngx_queue_insert_tail(&redis_connection_queue->queue, &conf->redis_context->queue);
    }

    if (!conf->redis_context->redis_context || conf->redis_context->redis_context->err) {
        if (conf->redis_context->redis_context) {
            redisFree(conf->redis_context->redis_context);
        }

        conf->redis_context->redis_context = redisConnect((char *) conf->redis_hostname.data, conf->redis_port);

        if (!conf->redis_context->redis_context) {
            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "Error connecting to Redis: cannot allocate redis context");
            return NULL;
        }

        redisReply* reply = redisCommand(conf->redis_context->redis_context, "SELECT %d", conf->redis_db);

        if (!reply || reply->type == REDIS_REPLY_ERROR) {
            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "Error connecting to Redis: cannot select the correct database");
            return NULL;
        }

        if (reply->type == REDIS_REPLY_STRING) {
            ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0, "Redis database [%d] selected", conf->redis_db);
            freeReplyObject(reply);
        }
    }

    return conf->redis_context->redis_context;
}
开发者ID:dx7,项目名称:ngx-http-dynamic-redirect-module,代码行数:39,代码来源:ngx_http_dynamic_redirect_module.c


示例19: clear_key

int clear_key(char *key)
{
	int fd;
	redisReply *ret;

	ret = redisConnect(&fd, "127.0.0.1", 6379);
	if (NULL != ret) {
		DINFO("connect error! %s\n", ret->reply);
		return -1;
	}
	
	ret = redisCommand(fd, "DEL %s", key);
	if (ret->type != REDIS_REPLY_INTEGER) {
		DINFO("DEL %s error! ret: %d, %s\n", key, ret->type, ret->reply);
		return -2;
	}
	freeReplyObject(ret);
	
	close(fd);
	
	return 0;
}
开发者ID:cygsxak,项目名称:memlink,代码行数:22,代码来源:testredis.c


示例20: db_plugin_verify

int db_plugin_verify(char *pluginkey)
{
  redisReply *reply;
  bool valid = false;

  if (!rc)
    return (-1);

  reply = redisCommand(rc, "Exists %s", pluginkey);

  if (reply->type != REDIS_REPLY_INTEGER)
    LOG_WARNING("Redis failed to query plugin key existence: %s", reply->str);
  else
    valid = reply->integer == 1;

  freeReplyObject(reply);

  if (!valid)
    return (-1);

  return (0);
}
开发者ID:splone,项目名称:splonebox-core,代码行数:22,代码来源:plugin.c



注:本文中的freeReplyObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ freeResources函数代码示例发布时间:2022-05-30
下一篇:
C++ freeNode函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap