Esempio n. 1
0
void TestRpoplpush( )
{
	try
	{
		CRedisClient redis;
		redis.connect("127.0.0.1", 6379);

        string value;
        bool flag = redis.rpoplpush("source", "dest", value);
		cout << flag << endl;
        cout << "value:" << value << endl;
	} catch( RdException& e )
	{
		std::cout << "Redis exception:" << e.what() << std::endl;
	} catch( Poco::Exception& e )
	{
		std::cout << "Poco_exception:" << e.what() << std::endl;
	}
}
Esempio n. 2
0
void TestRpoplpush( )
{
	try
	{
		CRedisClient redis;
		redis.connect("127.0.0.1", 6379);

		string source = "source";
		string dest = "dest";
//		CRedisClient::VecString srcValue;
//		srcValue.push_back("a");
//		srcValue.push_back("b");
//		srcValue.push_back("c");
//		CRedisClient::VecString destValue;
//		destValue.push_back("1");
//		destValue.push_back("2");
//		destValue.push_back("3");
//
//		redis.rpush(source, srcValue);
//		redis.rpush(dest, destValue);
//		srcValue.clear();
//		destValue.clear();
//
//		cout << "before test rpoplpush......" << endl;
//		cout << "old source.............." << endl;
//		int64_t start = 0;
//		int64_t stop = 2;
//		redis.lrange(source, start, stop, srcValue);
//		for ( CRedisClient::VecString::const_iterator it = srcValue.begin() ; it != srcValue.end() ;
//				it++ )
//		{
//			cout << *it << endl;
//		}
//		redis.lrange(dest, start, stop, destValue);
//		cout << "old dest.........." << endl;
//		for ( CRedisClient::VecString::const_iterator it = destValue.begin() ;
//				it != destValue.end() ; it++ )
//		{
//			cout << *it << endl;
//		}
//		srcValue.clear();
//		destValue.clear();
//
//		cout << "after test rpoplpush........" << endl;
		string value;
		bool flag = redis.rpoplpush(source, dest, value);
		cout << flag << endl;
		cout << "value====================" << value << endl;

//		int64_t start_new = 0;
//		int64_t stop_new = 20;
//		redis.lrange(source, start_new, stop_new, srcValue);
//		redis.lrange(dest, start_new, stop_new, destValue);
//		cout << "new source................" << endl;
//		for ( CRedisClient::VecString::const_iterator it = srcValue.begin() ; it != srcValue.end() ;
//				it++ )
//		{
//			cout << *it << endl;
//		}
//		cout << "new dest..................." << endl;
//		for ( CRedisClient::VecString::const_iterator it = destValue.begin() ;
//				it != destValue.end() ; it++ )
//		{
//			cout << *it << endl;
//		}

	} catch( RdException& e )
	{
		std::cout << "Redis exception:" << e.what() << std::endl;
	} catch( Poco::Exception& e )
	{
		std::cout << "Poco_exception:" << e.what() << std::endl;
	}
}