当前位置: 首页>>代码示例>>C++>>正文


C++ redisFree函数代码示例

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


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

示例1: flushdb

 void flushdb()
 {
     Redis::Context* cxt = Application::context_map()->get(Prefix::user);
     redisContext* rdb = redisConnect(cxt->host.c_str(),cxt->port);
     redisReply* r = (redisReply*) redisCommand(rdb, "select %d", cxt->db_num);
     freeReplyObject(r);
     r = (redisReply*) redisCommand(rdb,"flushdb");
     freeReplyObject(r);
     redisFree(rdb);
 }
开发者ID:tomthorogood,项目名称:Mogu,代码行数:10,代码来源:UserManager.Test.cpp

示例2: redisFree

//-------------------------------------------------------------------------------------
bool DBInterfaceRedis::detach()
{
	if(pRedisContext_)
	{
		redisFree(pRedisContext_);
		pRedisContext_ = NULL;
	}
	
	return true;
}
开发者ID:BombShen,项目名称:kbengine,代码行数:11,代码来源:db_interface_redis.cpp

示例3: get

void get(char *key){
    redisContext* c = redisConnect("127.0.0.1", 6379);
    redisReply* r = (redisReply*)redisCommand(c,"get %s",key);
    if(r->type == REDIS_REPLY_STRING){
        printf("get value = %s",r->str);
    }

    freeReplyObject(r);
    redisFree(c);
}
开发者ID:yiwenshao,项目名称:MyDrill,代码行数:10,代码来源:main2.c

示例4: hiredis_backend__free

void hiredis_backend__free(git_odb_backend *_backend)
{
    hiredis_backend *backend;
    assert(_backend);
    backend = (hiredis_backend *) _backend;

    redisFree(backend->db);

    free(backend);
}
开发者ID:tuxdna,项目名称:libgit2-backends,代码行数:10,代码来源:hiredis.c

示例5: redisFree

bool RedisDriver::Reconnect()
{
	if (m_pContext != NULL)
	{
		redisFree(m_pContext);
		m_pContext = NULL;
	}
	XLog(LEVEL_ERROR, "[Redis]: reconnecting...\n");
	return Connect(m_sIP, m_nPort, m_sPwd, m_nConnTimeout);
}
开发者ID:txal,项目名称:XProject,代码行数:10,代码来源:RedisDriver.cpp

示例6: git_refdb_backend_hiredis

int git_refdb_backend_hiredis(git_refdb_backend **backend_out, const char* prefix, const char* path, const char *host, int port, char* password)
{
	hiredis_refdb_backend *backend;
	redisReply *reply;

	backend = calloc(1, sizeof(hiredis_refdb_backend));
	if (backend == NULL)
		return GITERR_NOMEMORY;

	if (sharedConnection == NULL) {
		sharedConnection = redisConnect(host, port);
		if (sharedConnection->err) {
			free(backend);
			giterr_set_str(GITERR_REFERENCE, "Redis refdb storage couldn't connect to redis server");
			return GIT_ERROR;
		}

		if (password != NULL) {
			reply = redisCommand(sharedConnection, "AUTH %s", password);
			if (reply->type == REDIS_REPLY_ERROR) {
				freeReplyObject(reply);
				redisFree(sharedConnection);
				free(backend);
				giterr_set_str(GITERR_REFERENCE, "Redis refdb storage authentication with redis server failed");
				return GIT_ERROR;
			}
			freeReplyObject(reply);
		}
	}

	backend->db = sharedConnection;

	backend->prefix = strdup(prefix);
	backend->repo_path = strdup(path);

	backend->parent.exists = &hiredis_refdb_backend__exists;
	backend->parent.lookup = &hiredis_refdb_backend__lookup;
	backend->parent.iterator = &hiredis_refdb_backend__iterator;
	backend->parent.write = &hiredis_refdb_backend__write;
	backend->parent.del = &hiredis_refdb_backend__del;
	backend->parent.rename = &hiredis_refdb_backend__rename;
	backend->parent.compress = NULL;
	backend->parent.free = &hiredis_refdb_backend__free;

	backend->parent.has_log = &hiredis_refdb_backend__has_log;
	backend->parent.ensure_log = &hiredis_refdb_backend__ensure_log;
	backend->parent.reflog_read = &hiredis_refdb_backend__reflog_read;
	backend->parent.reflog_write = &hiredis_refdb_backend__reflog_write;
	backend->parent.reflog_rename = &hiredis_refdb_backend__reflog_rename;
	backend->parent.reflog_delete = &hiredis_refdb_backend__reflog_delete;

	*backend_out = (git_refdb_backend *) backend;

	return GIT_OK;
}
开发者ID:ideal,项目名称:libgit2-backends,代码行数:55,代码来源:hiredis.c

示例7: check_contents

static int check_contents(request_rec *req)
{
    llzr_config *conf = ap_get_module_config (c->base_server->module_config,  &llzr_module);
    GTable *post_data = get_post_data(req);
    redis = conf->redisconn;
    reply = conf->redisreply;

    /*
        Things of interest:

        request_rec->uri
        request_rec->useragent_ip
        request_rec->request_time
        request_rec->method
    */

    char *request_remote_ip         = recq->useragent_ip;
    apr_time_t request_timestamp    = recq->request_time;
    char *request_uri               = recq->uri;
    char *request_method            = recq->method;

   /*

        @TODO: look through post request for username and password

        if they are included, create a token id, and insert into redis database
        send back a 402 payment required or 307 to /login/token
        ask the user to authorize login...
        on resubmission ony the token is passed and if exists, login is sucessful
        if not, the entry is logged and evaluated

   */

    /*
    ...
     */
    if (post_data) {

        /* ... hash the password to be secure in memory even.. */
        size_t length = sizeof(post_data['USERNAME_FIELD']);
        unsigned char hash[SHA_DIGEST_LENGTH];
        SHA1(post_data['USERNAME_FIELD'], length, hash);

        reply = redisCommand(redis, "HMSET %s %s %s", request_remote_ip, username, hash);

    }
    /*
    ...
     */

    redisFreeReply(reply);
    redisFree(redis);

    return OK;
}
开发者ID:mikemackintosh,项目名称:Apache-LoginLimitizer,代码行数:55,代码来源:mod_llzr.c

示例8: cr_connect

SEXP cr_connect(SEXP sHost, SEXP sPort, SEXP sTimeout, SEXP sReconnect, SEXP sRetry) {
    const char *host = "localhost";
    double tout = Rf_asReal(sTimeout);
    int port = Rf_asInteger(sPort), reconnect = (Rf_asInteger(sReconnect) > 0),
	retry = (Rf_asInteger(sRetry) > 0);
    redisContext *ctx;
    rconn_t *c;
    SEXP res;
    struct timeval tv;

    if (TYPEOF(sHost) == STRSXP && LENGTH(sHost) > 0)
	host = CHAR(STRING_ELT(sHost, 0));

    tv.tv_sec = (int) tout;
    tv.tv_usec = (tout - (double)tv.tv_sec) * 1000000.0;
    if (port < 1)
	ctx = redisConnectUnixWithTimeout(host, tv);
    else
	ctx = redisConnectWithTimeout(host, port, tv);
    if (!ctx) Rf_error("connect to redis failed (NULL context)");
    if (ctx->err){
	SEXP es = Rf_mkChar(ctx->errstr);
	redisFree(ctx);
	Rf_error("connect to redis failed: %s", CHAR(es));
    }
    c = malloc(sizeof(rconn_t));
    if (!c) {
	redisFree(ctx);
	Rf_error("unable to allocate connection context");
    }
    c->rc = ctx;
    c->flags = (reconnect ? RCF_RECONNECT : 0) | (retry ? RCF_RETRY : 0);
    c->host  = strdup(host);
    c->port  = port;
    c->timeout = tout;
    redisSetTimeout(ctx, tv);
    res = PROTECT(R_MakeExternalPtr(c, R_NilValue, R_NilValue));
    Rf_setAttrib(res, R_ClassSymbol, Rf_mkString("redisConnection"));
    R_RegisterCFinalizer(res, rconn_fin);
    UNPROTECT(1);
    return res;
}
开发者ID:nandakishorkoka,项目名称:rediscc,代码行数:42,代码来源:credis.c

示例9: main

int main()
{
    redisContext* r {redisConnect("localhost",6379)};
    freeReplyObject(redisCommand(r, "flushall"));
    redisFree(r);

    populate_users();
    Test::TextOutput o(Test::TextOutput::Verbose);
    GMTS test {};
    return test.run(o) ? EXIT_SUCCESS : EXIT_FAILURE;
}
开发者ID:tomthorogood,项目名称:Mogu,代码行数:11,代码来源:GroupManager.Test.cpp

示例10: guard

bool CRedisClient::ReConnect()
{
	LockerGuard guard(*m_locker);
	if( m_pRedisContext )
	{
		redisFree(m_pRedisContext);
		m_pRedisContext = NULL;
	}
	struct timeval timeout = { 0, 500000 }; // 0.5 seconds 重连
	return OnConnect(&timeout);
}
开发者ID:ZZMarquis,项目名称:NetServer,代码行数:11,代码来源:CRedisClient.cpp

示例11: init_thread

void init_thread(evhtp_t *htp, evthr_t *thread, void *arg)
{
    thr_arg_t *thr_args;
    thr_args = calloc(1, sizeof(thr_arg_t));
    thr_args->thread = thread;

    char mserver[32];

    if(settings.cache_on == true)
    {
        memcached_st *memc = memcached_create(NULL);
        snprintf(mserver, 32, "%s:%d", settings.cache_ip, settings.cache_port);
        memcached_server_st *servers = memcached_servers_parse(mserver);
        memcached_server_push(memc, servers);
        memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
        memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1); 
        memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1); 
        memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, 1); 
        thr_args->cache_conn = memc;
        LOG_PRINT(LOG_DEBUG, "Memcached Connection Init Finished.");
        memcached_server_list_free(servers);
    }

    if(settings.mode == 2)
    {
        memcached_st *beans = memcached_create(NULL);
        snprintf(mserver, 32, "%s:%d", settings.beansdb_ip, settings.beansdb_port);
        memcached_server_st *servers = memcached_servers_parse(mserver);
        servers = memcached_servers_parse(mserver);
        memcached_server_push(beans, servers);
        memcached_behavior_set(beans, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 0);
        memcached_behavior_set(beans, MEMCACHED_BEHAVIOR_NO_BLOCK, 1); 
        memcached_behavior_set(beans, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, 1); 
        thr_args->beansdb_conn = beans;
        LOG_PRINT(LOG_DEBUG, "beansdb Connection Init Finished.");
        memcached_server_list_free(servers);
    }
    else if(settings.mode == 3)
    {
        redisContext* c = redisConnect(settings.ssdb_ip, settings.ssdb_port);
        if(c->err)
        {
            redisFree(c);
            LOG_PRINT(LOG_DEBUG, "Connect to ssdb server faile");
        }
        else
        {
            thr_args->ssdb_conn = c;
            LOG_PRINT(LOG_DEBUG, "Connect to ssdb server Success");
        }
    }

    evthr_set_aux(thread, thr_args);
}
开发者ID:winsky027,项目名称:zimg,代码行数:54,代码来源:main.c

示例12: LOG

void RedisClientPool::Destroy(redisContext* item)
{
	if (item)
	{
		stringstream stream;
		stream << "free redis context";
		LOG(INFO, stream.str());

		redisFree(item);
	}
}
开发者ID:abigbigbird,项目名称:CodisClient,代码行数:11,代码来源:RedisClientPool.cpp

示例13: redisFree

RedisOperator::~RedisOperator()
{
    if(this->ctx)
    {
        redisFree(this->ctx);
        this->ctx = NULL;
    }
    this->host.resize(0);
    this->port = -1;
    this->password.resize(0);
}
开发者ID:coco-zj,项目名称:demo,代码行数:11,代码来源:RedisOperator.cpp

示例14: redisConnect

HashNodeGenerator::HashNodeGenerator (const std::string& node)
{
	redisContext* rdb = redisConnect(REDIS_HOST, REDIS_PORT);
	__reply = (redisReply*) redisCommand(rdb, "type %s", node.c_str());
	assert(strcmp(__reply->str,"hash") == 0);
	freeReplyObject(__reply);

	__reply = (redisReply*) redisCommand(rdb, "hgetall %s", node.c_str());
	redisFree(rdb);
	current =0;
}
开发者ID:reolyze,项目名称:Mogu,代码行数:11,代码来源:HashNodeGenerator.cpp

示例15: redis_connection

/* Internal methods */
static redisContext* redis_connection(struct redis_handler *handle)
{
	redisContext* context = NULL;
	struct timeval timeout = { 1, 500000 }; // 1.5 seconds
	context = redisConnectWithTimeout((char*)handle->redis_ip, handle->redis_port, timeout);
	if (context == NULL || context->err) {
		if (context != NULL) {
			redisFree(context);
		}
		return NULL;
	}
	/* make keepalive connection */
	if (redisEnableKeepAlive(context) != REDIS_OK){
		if (context != NULL) {
			redisFree(context);
		}
		return NULL;
	}
	return context;
}
开发者ID:Navaneethsen,项目名称:elijah-cloudlet,代码行数:21,代码来源:redis.c


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