redis:list数据类型与操作

redis数据类型之list:redis list数据类型是一个双向循环链表。redis.conf中的相关配置如下:

428 # Similarly to hashes, small lists are also encoded in a special way in order
429 # to save a lot of space. The special representation is only used when
430 # you are under the following limits:
431 list-max-ziplist-entries 512
432 list-max-ziplist-value 64

对于list的操作详见: http://redis.readthedocs.org/en/2.4/list.html


redis c++接口的调用:

#include "redisclient.h"

#include "tests/functions.h"

#include 

#include 

#define OUT(x) std::cout<<#x<<" = "< init_non_cluster_client();

void test_list(redis::client & c);

int main(int argv, char* argc[]) 
{
	boost::shared_ptr shared_c;

	shared_c = init_non_cluster_client();

	redis::client& c = *shared_c;

	test_list(c);

	return 0;
}
void test_list(redis::client & c)
{
	test("test redis list type.");

	while(c.llen("list")>0) {
		OUT(c.lpop("list"));
	}

	test("lpush & rpush & lpop & rpop & blpop & brpop");
	{
		OUT( c.lpush("list", "lpush1") );
		OUT( c.lpush("list", "lpush2") );
		OUT( c.rpush("list", "rpush1") );
		OUT( c.rpush("list", "rpush2") );
		OUT( c.llen("list") );

		redis::client::string_vector out;
		OUT( c.lrange("list", 0, 10, out) );
		for(size_t i=0; i


你可能感兴趣的:(redis学习)