本文整理汇总了C++中Ardb::LClear方法的典型用法代码示例。如果您正苦于以下问题:C++ Ardb::LClear方法的具体用法?C++ Ardb::LClear怎么用?C++ Ardb::LClear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ardb
的用法示例。
在下文中一共展示了Ardb::LClear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_sort_list
void test_sort_list(Ardb& db)
{
DBID dbid = 0;
db.LClear(dbid, "mylist");
db.RPush(dbid, "mylist", "100");
db.RPush(dbid, "mylist", "10");
db.RPush(dbid, "mylist", "9");
db.RPush(dbid, "mylist", "1000");
StringArray args;
ValueDataArray vs;
db.Sort(dbid, "mylist", args, vs);
CHECK_FATAL(vs.size() != 4, "sort result size error:%zu", vs.size());
CHECK_FATAL(vs[0].integer_value != 9, "sort result[0]:%"PRId64, vs[0].integer_value);
CHECK_FATAL(vs[1].integer_value != 10, "sort result[0]:%"PRId64, vs[1].integer_value);
CHECK_FATAL(vs[2].integer_value != 100, "sort result[0]:%"PRId64, vs[2].integer_value);
CHECK_FATAL(vs[3].integer_value != 1000, "sort result[0]:%"PRId64, vs[3].integer_value);
vs.clear();
args.clear();
string_to_string_array("limit 1 2", args);
db.Sort(dbid, "mylist", args, vs);
CHECK_FATAL(vs.size() != 2, "sort result size error:%zu", vs.size());
CHECK_FATAL(vs[0].integer_value != 10, "sort result[0]:%"PRId64, vs[0].integer_value);
CHECK_FATAL(vs[1].integer_value != 100, "sort result[0]:%"PRId64, vs[1].integer_value);
vs.clear();
args.clear();
string_to_string_array("by weight_*", args);
db.Set(dbid, "weight_100", "1000");
db.Set(dbid, "weight_10", "900");
db.Set(dbid, "weight_9", "800");
db.Set(dbid, "weight_1000", "700");
db.Sort(dbid, "mylist", args, vs);
CHECK_FATAL(vs.size() != 4, "sort result size error:%zu", vs.size());
CHECK_FATAL(vs[0].integer_value != 1000, "sort result[0]:%"PRId64, vs[0].integer_value);
CHECK_FATAL(vs[1].integer_value != 9, "sort result[0]:%"PRId64, vs[1].integer_value);
CHECK_FATAL(vs[2].integer_value != 10, "sort result[0]:%"PRId64, vs[2].integer_value);
CHECK_FATAL(vs[3].integer_value != 100, "sort result[0]:%"PRId64, vs[3].integer_value);
db.HSet(dbid, "myhash", "field_100", "hash100");
db.HSet(dbid, "myhash", "field_10", "hash10");
db.HSet(dbid, "myhash", "field_9", "hash9");
db.HSet(dbid, "myhash", "field_1000", "hash1000");
args.clear();
string_to_string_array("by weight_* get myhash->field_* get #", args);
vs.clear();
db.Sort(dbid, "mylist", args, vs);
std::string str;
CHECK_FATAL(vs.size() != 8, "sort result size error:%zu", vs.size());
CHECK_FATAL(vs[0].ToString(str) != "hash1000", "sort result[0]:%s", str.c_str());
CHECK_FATAL(vs[2].ToString(str) != "hash9", "sort result[2]:%s", str.c_str());
CHECK_FATAL(vs[4].ToString(str) != "hash10", "sort result[4]:%s", str.c_str());
CHECK_FATAL(vs[6].ToString(str) != "hash100", "sort result[6]:%s", str.c_str());
CHECK_FATAL(vs[1].integer_value != 1000, "sort result[1]:%"PRId64, vs[1].integer_value);
CHECK_FATAL(vs[3].integer_value != 9, "sort result[3]:%"PRId64, vs[3].integer_value);
CHECK_FATAL(vs[5].integer_value != 10, "sort result[5]:%"PRId64, vs[5].integer_value);
CHECK_FATAL(vs[7].integer_value != 100, "sort result[7]:%"PRId64, vs[7].integer_value);
}