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


C++ Ardb类代码示例

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


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

示例1: test_strings_strlen

void test_strings_strlen(Ardb& db)
{
    DBID dbid = 0;
    db.Set(dbid, "skey", "abcabcabc");
    int len = db.Strlen(dbid, "skey");
    CHECK_FATAL(len != 9, "Strlen failed:%d", len);
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:7,代码来源:strings_testcase.cpp

示例2: main

int main(int argc, char** argv)
{
    std::string dir;
    if (argc >= 2)
    {
        int j = 1; /* First option to parse in argv[] */
        char *dirfile = NULL;

        /* Handle special options --help and --version */
        if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)
            version();
        if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)
            usage();

        /* First argument is the config file name? */
        if (argv[j][0] != '-' || argv[j][1] != '-')
        {
            dirfile = argv[j++];
            dir = dirfile;
        }
    }
    else
    {
        printf("Warning: no database dir specified to repair.\n");
        return -1;
    }

    Ardb db;
    return db.Repair(dir);
}
开发者ID:omegablitz,项目名称:ardb,代码行数:30,代码来源:repair.cpp

示例3: test_strings_getrange

void test_strings_getrange(Ardb& db)
{
    DBID dbid = 0;
    std::string v;
    db.Set(dbid, "skey", "abcabc");
    db.GetRange(dbid, "skey", 4, -1, v);
    CHECK_FATAL(v != "bc", "GetRange failed");
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:8,代码来源:strings_testcase.cpp

示例4: test_strings_exists

void test_strings_exists(Ardb& db)
{
    DBID dbid = 0;
    db.Del(dbid, "intkey1");
    CHECK_FATAL(db.Exists(dbid, "intkey1"), "Exists intkey1 failed");
    db.Set(dbid, "intkey1", "123");
    CHECK_FATAL(db.Exists(dbid, "intkey1") == false, "Exists intkey failed");
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:8,代码来源:strings_testcase.cpp

示例5: test_strings_setnx

void test_strings_setnx(Ardb& db)
{
    DBID dbid = 0;
    db.Set(dbid, "intkey1", "123");
    CHECK_FATAL(db.SetNX(dbid, "intkey1", "2345") == 0, "SetNX intkey failed");
    db.Del(dbid, "intkey1");
    CHECK_FATAL(db.SetNX(dbid, "intkey1", "2345") != 0, "SetNX intkey failed");
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:8,代码来源:strings_testcase.cpp

示例6: test_strings_getset

void test_strings_getset(Ardb& db)
{
    DBID dbid = 0;
    std::string v;
    db.Set(dbid, "skey", "abcabc");
    db.GetSet(dbid, "skey", "edfgth", v);
    CHECK_FATAL(v != "abcabc", "GetSet failed:%s", v.c_str());
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:8,代码来源:strings_testcase.cpp

示例7: test_strings_setrange

void test_strings_setrange(Ardb& db)
{
    DBID dbid = 0;
    std::string v;
    db.Set(dbid, "skey", "abcabc");
    db.SetRange(dbid, "skey", 3, "12345");
    db.Get(dbid, "skey", v);
    CHECK_FATAL(v != "abc12345", "SetRange failed:%s", v.c_str());
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:9,代码来源:strings_testcase.cpp

示例8: test_strings_expire

void test_strings_expire(Ardb& db)
{
    DBID dbid = 0;
    ValueData v;
    db.Set(dbid, "intkey1", "123");
    db.Expire(dbid, "intkey1", 1);
    CHECK_FATAL(db.Exists(dbid, "intkey1") == false, "Expire intkey1 failed");
    sleep(2);
    CHECK_FATAL(db.Exists(dbid, "intkey1") == true, "Expire intkey failed");
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:10,代码来源:strings_testcase.cpp

示例9: test_set_expire

void test_set_expire(Ardb& db)
{
	DBID dbid = 0;
	db.SClear(dbid, "myset");
	db.SAdd(dbid, "myset", "123");
	db.Expire(dbid, "myset", 1);
	CHECK_FATAL(db.Exists(dbid, "myset") == false, "Expire myset failed");
	sleep(2);
	CHECK_FATAL(db.Exists(dbid, "myset") == true, "Expire myset failed");
}
开发者ID:Ivasek,项目名称:ardb,代码行数:10,代码来源:sets_testcase.cpp

示例10: test_strings_decr

void test_strings_decr(Ardb& db)
{
    DBID dbid = 0;
    db.Set(dbid, "intkey", "10");
    int64_t iv = 0;
    db.Decr(dbid, "intkey", iv);
    CHECK_FATAL(iv != 9, "Decr1 failed %"PRId64, iv);
    db.Decrby(dbid, "intkey", 2, iv);
    CHECK_FATAL(iv != 7, "Decrby failed: %"PRId64, iv);
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:10,代码来源:strings_testcase.cpp

示例11: test_zset_expire

void test_zset_expire(Ardb& db)
{
    DBID dbid = 0;
    db.ZClear(dbid, "myzset");
    db.ZAdd(dbid, "myzset", ValueData((int64) 1), "one");
    db.Expire(dbid, "myzset", 1);
    CHECK_FATAL(db.Exists(dbid, "myzset") == false, "Expire myzset failed");
    sleep(2);
    CHECK_FATAL(db.Exists(dbid, "myzset") == true, "Expire myzset failed");
}
开发者ID:rchunping,项目名称:ardb,代码行数:10,代码来源:zset_testcase.cpp

示例12: test_set_union

void test_set_union(Ardb& db)
{
	DBID dbid = 0;
	db.SClear(dbid, "myset1");
	db.SClear(dbid, "myset2");
	db.SClear(dbid, "myset3");
	db.SAdd(dbid, "myset1", "a");
	db.SAdd(dbid, "myset1", "b");
	db.SAdd(dbid, "myset1", "c");
	db.SAdd(dbid, "myset1", "d");
	db.SAdd(dbid, "myset2", "c");
	db.SAdd(dbid, "myset3", "a");
	db.SAdd(dbid, "myset3", "c");
	db.SAdd(dbid, "myset3", "e");

	SliceArray keys;
	keys.push_back("myset1");
	keys.push_back("myset2");
	keys.push_back("myset3");
	ValueArray values;
	db.SUnion(dbid, keys, values);
	CHECK_FATAL(values.size() != 5, "SUnion failed:");
	std::string str;
	CHECK_FATAL( values.begin()->ToString(str) != "a", "SUnion store failed:");
	db.SUnionStore(dbid, "myset2", keys);
	CHECK_FATAL(db.SCard(dbid, "myset2") != 5, "SUnionStore myset2 failed:");
}
开发者ID:kouhate,项目名称:ardb,代码行数:27,代码来源:sets_testcase.cpp

示例13: test_set_inter

void test_set_inter(Ardb& db)
{
	DBID dbid = 0;
	db.SClear(dbid, "myset1");
	db.SClear(dbid, "myset2");
	db.SClear(dbid, "myset3");
	db.SAdd(dbid, "myset1", "a");
	db.SAdd(dbid, "myset1", "b");
	db.SAdd(dbid, "myset1", "c");
	db.SAdd(dbid, "myset1", "d");
	db.SAdd(dbid, "myset2", "c");
	db.SAdd(dbid, "myset3", "a");
	db.SAdd(dbid, "myset3", "c");
	db.SAdd(dbid, "myset3", "e");

	SliceArray keys;
	keys.push_back("myset1");
	keys.push_back("myset2");
	keys.push_back("myset3");
	ValueSet values;
	db.SInter(dbid, keys, values);
	std::string str;
	CHECK_FATAL( values.size() != 1, "Sinter failed:");
	CHECK_FATAL(values.begin()->ToString(str) != "c", "Sinter store failed:");
	db.SInterStore(dbid, "myset2", keys);
	CHECK_FATAL( db.SCard(dbid, "myset2") != 1, "SInterStore myset2 failed:");
}
开发者ID:ericcapricorn,项目名称:ardb,代码行数:27,代码来源:sets_testcase.cpp

示例14: test_set_diff

void test_set_diff(Ardb& db)
{
	DBID dbid = 0;
	db.SClear(dbid, "myset1");
	db.SClear(dbid, "myset2");
	db.SClear(dbid, "myset3");
	db.SAdd(dbid, "myset1", "a");
	db.SAdd(dbid, "myset1", "b");
	db.SAdd(dbid, "myset1", "c");
	db.SAdd(dbid, "myset1", "d");
	db.SAdd(dbid, "myset2", "c");
	db.SAdd(dbid, "myset3", "a");
	db.SAdd(dbid, "myset3", "c");
	db.SAdd(dbid, "myset3", "e");

	std::string str;
	SliceArray keys;
	keys.push_back("myset1");
	keys.push_back("myset2");
	keys.push_back("myset3");
	ValueSet values;
	db.SDiff(dbid, keys, values);
	CHECK_FATAL(values.size() != 2, "Sdiff failed:");
	CHECK_FATAL(values.begin()->ToString(str) != "b", "Sdiff store failed:");
	//CHECK_FATAL(FATAL, values[1] != "d") << "Sdiff store failed:";
	int len = db.SDiffStore(dbid, "myset2", keys);
	CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
	len = db.SCard(dbid, "myset2");
	CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
}
开发者ID:ericcapricorn,项目名称:ardb,代码行数:30,代码来源:sets_testcase.cpp

示例15: test_strings_incr

void test_strings_incr(Ardb& db)
{
    DBID dbid = 0;
    db.Set(dbid, "intkey", "12");
    int64_t iv = 0;
    db.Incrby(dbid, "intkey", 2, iv);
    CHECK_FATAL(iv != 14, "Incrby failed");
    double dv;
    db.IncrbyFloat(dbid, "intkey", 1.23, dv);
    CHECK_FATAL(dv != 15.23, "IncrbyFloat failed");
}
开发者ID:DirektSPEED,项目名称:ardb,代码行数:11,代码来源:strings_testcase.cpp


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