Exemple #1
0
void test_keys(Ardb& db)
{
    DBID dbid = 0;
    db.HSet(dbid, "myhash_v0", "field", "100");
    db.SAdd(dbid, "myset_v0", "field");
    db.LPush(dbid, "mylist", "122");
    db.ZAdd(dbid, "myzset", ValueData((int64) 3), "v0");
    db.Set(dbid, "mykey", "12312");

    StringArray ret;
    db.Keys(dbid, "my*", "", 100, ret);
    CHECK_FATAL(ret.size() < 5, "keys my* size error:%zu", ret.size());
    ret.clear();
    db.Keys(dbid, "*set*", "", 100, ret);
    CHECK_FATAL(ret.size() < 2, "keys *set* size error:%zu", ret.size());
}
Exemple #2
0
void test_type(Ardb& db)
{
    DBID dbid = 0;
    db.SAdd(dbid, "myset", "123");
    db.LPush(dbid, "mylist", "value0");
    db.ZAdd(dbid, "myzset1", ValueData((int64) 1), "one");
    db.HSet(dbid, "myhash", "field1", "value1");
    db.Set(dbid, "skey", "abc");
    db.SetBit(dbid, "mybits", 1, 1);

    CHECK_FATAL(db.Type(dbid, "myset") != SET_META, "type failed.");
    CHECK_FATAL(db.Type(dbid, "mylist") != LIST_META, "type failed.");
    CHECK_FATAL(db.Type(dbid, "myzset1") != ZSET_META, "type failed.");
    CHECK_FATAL(db.Type(dbid, "myhash") != HASH_META, "type failed.");
    CHECK_FATAL(db.Type(dbid, "skey") != STRING_META, "type failed.");
    CHECK_FATAL(db.Type(dbid, "mybits") != BITSET_META, "type failed.");
}