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


C++ redis_zset::clear方法代码示例

本文整理汇总了C++中acl::redis_zset::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ redis_zset::clear方法的具体用法?C++ redis_zset::clear怎么用?C++ redis_zset::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在acl::redis_zset的用法示例。


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

示例1: test_zinterstore

static bool test_zinterstore(acl::redis_zset& redis ,int n)
{
	acl::string dest_key, src1_key, src2_key;
	std::vector<acl::string> src_keys;

	for (int i = 0; i < n; i++)
	{
		dest_key.format("zset_dest_key_%d", i);
		src1_key.format("zset_src1_key_%d", i);
		src_keys.push_back(src1_key);
		src2_key.format("zset_src2_key_%d", i);
		src_keys.push_back(src2_key);

		redis.clear();
		int ret = redis.zinterstore(dest_key.c_str(), src_keys);
		if (ret < 0)
		{
			printf("zinterstore error, dest: %s\r\n",
				dest_key.c_str());
			return false;
		}
		src_keys.clear();
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:26,代码来源:redis_zset.cpp

示例2: test_zincrby

static bool test_zincrby(acl::redis_zset& redis, int n)
{
	acl::string key;
	double inc = 2.5, result;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			if (redis.zincrby(key.c_str(), inc, member.c_str(),
				&result) == false)
			{
				printf("zincrby error, key: %s\r\n", key.c_str());
				return false;
			}
			else if (j < 10 && i * j < 100)
				printf("zincrby ok key: %s, result: %.2f\r\n",
					key.c_str(), result);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:28,代码来源:redis_zset.cpp

示例3: test_zrangebylex

static bool test_zrangebylex(acl::redis_zset& redis, int n)
{
	acl::string key;
	const char* min = "[aaa", *max = "(g";
	std::vector<acl::string> result;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		int ret = redis.zrangebylex(key.c_str(), min, max, &result);
		if (ret < 0)
		{
			printf("zrangebylex error(%s), key: %s\r\n",
				redis.result_error(), key.c_str());
			return false;
		}
		if (i >= 10)
		{
			result.clear();
			continue;
		}

		std::vector<acl::string>::const_iterator cit;
		for (cit = result.begin(); cit != result.end(); ++cit)
		{
			if (cit != result.begin())
				printf(", ");
			printf("%s", (*cit).c_str());
		}
		printf("\r\n");
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:35,代码来源:redis_zset.cpp

示例4: test_zadd

static bool test_zadd(acl::redis_zset& redis, int n)
{
	acl::string key;
	std::map<acl::string, double> members;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			members[member] = j;
		}

		redis.clear();
		int ret = redis.zadd(key, members);
		if (ret < 0)
		{
			printf("add key: %s error\r\n", key.c_str());
			return false;
		}
		else if (i < 10)
			printf("add ok, key: %s, ret: %d\r\n",
				key.c_str(), ret);
		members.clear();
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:31,代码来源:redis_zset.cpp

示例5: test_zscore

static bool test_zscore(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;
	bool ret;
	double result;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			ret = redis.zscore(key.c_str(), member.c_str(),
				result);
			if (ret == false)
			{
				printf("zscore error, key: %s\r\n",
					key.c_str());
				return false;
			}
			else if (j > 0 && j * i < 100)
				printf("zscore ok, key: %s, member:%s, "
					"score: %.2f\r\n", key.c_str(),
					member.c_str(), result);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:32,代码来源:redis_zset.cpp

示例6: test_zrem

static bool test_zrem(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;
	std::vector<acl::string> members;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 900; j < 1000; j++)
		{
			member.format("member_%d", j);
			members.push_back(member);
		}

		redis.clear();
		int ret = redis.zrem(key.c_str(), members);
		if (ret < 0)
		{
			printf("zrem error, key: %s\r\n", key.c_str());
			return false;
		}
		else if (i < 10)
			printf("zrem ok, key: %s, ret: %d\r\n",
				key.c_str(), ret);
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:30,代码来源:redis_zset.cpp

示例7: test_zrank

static bool test_zrank(acl::redis_zset& redis, int n)
{
	acl::string key;
	acl::string member;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);

		for (int j = 0; j < 1000; j++)
		{
			member.format("member_%d", j);
			redis.clear();
			int ret = redis.zrank(key.c_str(), member.c_str());
			if (ret < 0)
			{
				printf("zrank error, key: %s\r\n", key.c_str());
				return false;
			}
			else if (j > 0 && j * i < 100)
				printf("zrank ok, key: %s, member:%s, "
					"rank: %d\r\n", key.c_str(),
					member.c_str(), ret);
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:28,代码来源:redis_zset.cpp

示例8: test_zscan

static bool test_zscan(acl::redis_zset& redis, int n)
{
	acl::string key;
	int   ret = 0;
	std::vector<std::pair<acl::string, double> > result;
	std::vector<std::pair<acl::string, double> >::const_iterator cit;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		while (true)
		{
			redis.clear();
			ret = redis.zscan(key.c_str(), ret, result);
			if (ret < 0)
			{
				printf("zscan failed, key: %s\r\n",
					key.c_str());
				return false;
			}
			
			if (i >= 10)
			{
				if (ret == 0)
					break;
			}

			for (cit = result.begin(); cit != result.end(); ++cit)
			{
				printf("%s: %.2f\r\n", cit->first.c_str(),
					cit->second);
			}

			if (ret == 0)
			{
				printf("zscan over, key: %s\r\n", key.c_str());
				break;
			}
		}
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:43,代码来源:redis_zset.cpp

示例9: test_zcard

static bool test_zcard(acl::redis_zset& redis, int n)
{
	acl::string key;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		int ret = redis.zcard(key.c_str());
		if (ret < 0)
		{
			printf("zcard key: %s error\r\n", key.c_str());
			return false;
		}
		else if (i < 10)
			printf("zcard ok, key: %s, count: %d\r\n",
				key.c_str(), ret);
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:21,代码来源:redis_zset.cpp

示例10: test_zlexcount

static bool test_zlexcount(acl::redis_zset& redis, int n)
{
	acl::string key;
	const char* min = "[aaa", *max = "(g";

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		int ret = redis.zlexcount(key.c_str(), min, max);
		if (ret < 0)
		{
			printf("zlexcount error, key: %s\r\n", key.c_str());
			return false;
		}
		if (i >= 10)
			continue;
		printf("key: %s, count: %d\r\n", key.c_str(), ret);
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:22,代码来源:redis_zset.cpp

示例11: test_zrangebyscore

static bool test_zrangebyscore(acl::redis_zset& redis, int n)
{
	acl::string key;
	double min = 2, max = 10;

	printf("================test zrangebyscore=====================\r\n");
	std::vector<acl::string> result;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		result.clear();

		int ret = redis.zrangebyscore(key.c_str(), min, max, &result);
		if (ret < 0)
		{
			printf("zrangebyscore error, key: %s\r\n", key.c_str());
			return false;
		}
		else if (i >= 10)
		{
			result.clear();
			continue;
		}

		printf("zrangebyscore ok, key: %s, ret: %d\r\n",
			key.c_str(), ret);
		std::vector<acl::string>::const_iterator cit;
		for (cit = result.begin(); cit != result.end(); ++cit)
		{
			if (cit != result.begin())
				printf(", ");
			printf("%s", (*cit).c_str());
		}
		printf("\r\n");
		result.clear();
	}

	printf("===========test zrangebyscore_with_scores==============\r\n");
	std::vector<std::pair<acl::string, double> > result2;

	for (int i = 0; i < n; i++)
	{
		key.format("%s_%d", __keypre.c_str(), i);
		redis.clear();
		result.clear();

		int ret = redis.zrangebyscore_with_scores(key.c_str(),
			min, max, result2);
		if (ret < 0)
		{
			printf("zrangebyscore_with_scores error, key: %s\r\n",
				key.c_str());
			return false;
		}
		else if (i >= 10)
		{
			result2.clear();
			continue;
		}

		printf("zrangebyscore_with_scores ok, key: %s, ret: %d\r\n",
			key.c_str(), ret);
		std::vector<std::pair<acl::string, double> >::const_iterator cit;
		for (cit = result2.begin(); cit != result2.end(); ++cit)
		{
			if (cit != result2.begin())
				printf(", ");
			printf("%s: %.2f", cit->first.c_str(),
				cit->second);
		}
		printf("\r\n");
		result2.clear();
	}

	return true;
}
开发者ID:39608106,项目名称:acl,代码行数:78,代码来源:redis_zset.cpp


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