Esempio n. 1
0
void test_lists_pushx(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 10;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    RedisCommandFrame lpushx;
    lpushx.SetFullCommand("lpushx mylist value");
    db.Call(ctx, lpushx, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lpushx mylist failed");
    CHECK_FATAL(ctx.reply.integer != 0, "lpushx mylist failed");
    RedisCommandFrame rpushx;
    rpushx.SetFullCommand("rpushx mylist value");
    db.Call(ctx, rpushx, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "rpushx mylist failed");
    CHECK_FATAL(ctx.reply.integer != 0, "rpushx mylist failed");

    RedisCommandFrame mlpush;
    mlpush.SetFullCommand(
            "lpush mylist value10 value11 value12 value13 value10 value10 value10 value10 value10 value10");
    db.Call(ctx, mlpush, 0);
    db.Call(ctx, lpushx, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lpushx mylist failed");
    CHECK_FATAL(ctx.reply.integer != 11, "lpushx mylist failed");
    db.Call(ctx, rpushx, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "rpushx mylist failed");
    CHECK_FATAL(ctx.reply.integer != 12, "rpushx mylist failed");
}
Esempio n. 2
0
void test_lists_llen(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
    }
    RedisCommandFrame llen;
    llen.SetFullCommand("llen mylist");
    db.Call(ctx, llen, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "llen mylist failed");
    CHECK_FATAL(ctx.reply.integer != 10, "llen mylist failed");

    //non ziplist lpush
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist xvalue%d", i);
        db.Call(ctx, lpush, 0);
    }
    db.Call(ctx, llen, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "llen mylist failed");
    CHECK_FATAL(ctx.reply.integer != 20, "llen mylist failed");
}
Esempio n. 3
0
void test_lists_rpoplpush(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del, del1;
    del.SetFullCommand("del mylist");
    del1.SetFullCommand("del mylist1");
    db.Call(ctx, del, 0);
    db.Call(ctx, del1, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
    }
    RedisCommandFrame rpoplpush;
    rpoplpush.SetFullCommand("rpoplpush mylist mylist1");
    db.Call(ctx, rpoplpush, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "rpoplpush mylist failed");
    CHECK_FATAL(ctx.reply.str != "value0", "rpoplpush mylist failed");

    //non ziplist lpush
    for (int i = 0; i < 20; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist xvalue%d", i);
        db.Call(ctx, lpush, 0);
    }
    db.Call(ctx, rpoplpush, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "rpoplpush mylist failed");
    CHECK_FATAL(ctx.reply.str != "value1", "rpoplpush mylist failed");
}
Esempio n. 4
0
void test_bitset_bitop(Context& ctx, Ardb& db)
{
    RedisCommandFrame del;
    del.SetFullCommand("del mybitset1 mybitset2");
    db.Call(ctx, del, 0);

    for (uint32 i = 0; i < 4000; i++)
    {
        RedisCommandFrame setbit;
        setbit.SetFullCommand("setbit mybitset1 %u 1", i + 1000);
        db.Call(ctx, setbit, 0);
    }
    for (uint32 i = 0; i < 2000; i++)
    {
        RedisCommandFrame setbit;
        setbit.SetFullCommand("setbit mybitset2 %u 1", i + 4000);
        db.Call(ctx, setbit, 0);
    }

    RedisCommandFrame bitop;
    bitop.SetFullCommand("bitopcount and mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 1000, "bitopcount failed");
    bitop.SetFullCommand("bitopcount or mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 5000, "bitopcount failed");
    bitop.SetFullCommand("bitopcount xor mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 4000, "bitopcount failed");

    RedisCommandFrame bitcount;
    bitcount.SetFullCommand("bitcount mybitset3 0 -1");
    bitop.SetFullCommand("bitop and mybitset3 mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 1000, "bitopcount failed");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 1000, "bitcount failed");
    bitop.SetFullCommand("bitop or mybitset3 mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 5000, "bitopcount failed");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 5000, "bitcount failed");
    bitop.SetFullCommand("bitop xor mybitset3 mybitset1 mybitset2");
    db.Call(ctx, bitop, 0);
    CHECK_FATAL(ctx.reply.integer != 4000, "bitopcount failed");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 4000, "bitcount failed");

}
Esempio n. 5
0
void test_geo_common(Context& ctx, Ardb& db)
{
    db.GetConfig().zset_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mygeo");
    db.Call(ctx, del, 0);
    double x = 300.3;
    double y = 300.3;

    double p_x = 1000.0;
    double p_y = 1000.0;
    uint32 raius = 1000;
    uint32 total = 100000;
    GeoPointArray cmp;
    for (uint32 i = 0; i < total; i++)
    {
        char name[100];
        sprintf(name, "p%u", i);
        /*
         * min accuracy is 0.2meters
         */
        double xx = x + i * 0.3;
        double yy = y + i * 0.3;
        if (((xx - p_x) * (xx - p_x) + (yy - p_y) * (yy - p_y)) <= raius * raius)
        {
            GeoPoint p;
            p.x = xx;
            p.y = yy;
            cmp.push_back(p);
        }
        RedisCommandFrame geoadd;
        geoadd.SetFullCommand("geoadd mygeo MERCATOR %.2f %.2f %s", xx, yy, name);
        db.Call(ctx, geoadd, 0);
    }

    RedisCommandFrame zcard;
    zcard.SetFullCommand("zcard mygeo");
    db.Call(ctx, zcard, 0);
    CHECK_FATAL(ctx.reply.integer != total, "geoadd failed");
    RedisCommandFrame geosearch;
    geosearch.SetFullCommand("geosearch mygeo MERCATOR %.2f %.2f radius %d ASC WITHCOORDINATES WITHDISTANCES", p_x, p_y,
            raius);
    db.Call(ctx, geosearch, 0);
    CHECK_FATAL(ctx.reply.MemberSize() != cmp.size() * 4, "geosearch failed");
}
Esempio n. 6
0
void test_lists_lrem(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist valuexx");
        db.Call(ctx, lpush, 0);
    }
    RedisCommandFrame lrem;
    lrem.SetFullCommand("lrem mylist 2 valueyy");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 0, "lrem mylist failed");
    lrem.SetFullCommand("lrem mylist -2 valuexx");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 2, "lrem mylist failed");
    lrem.SetFullCommand("lrem mylist 0 valuexx");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 8, "lrem mylist failed");

    //non ziplist lpush
    for (int i = 0; i < 20; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist valuexx");
        db.Call(ctx, lpush, 0);
    }
    lrem.SetFullCommand("lrem mylist -2 valueyy");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 0, "lrem mylist failed");
    lrem.SetFullCommand("lrem mylist -2 valuexx");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 2, "lrem mylist failed");
    lrem.SetFullCommand("lrem mylist 0 valuexx");
    db.Call(ctx, lrem, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lrem mylist failed");
    CHECK_FATAL(ctx.reply.integer != 18, "lrem mylist failed");
}
Esempio n. 7
0
void test_lists_push(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
        CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lpush mylist failed");
        CHECK_FATAL(ctx.reply.integer != i + 1, "lpush mylist failed");
    }
    RedisCommandFrame mlpush;
    mlpush.SetFullCommand("lpush mylist value10 value11 value12");
    db.Call(ctx, mlpush, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lpush mylist failed");
    CHECK_FATAL(ctx.reply.integer != 13, "lpush mylist failed");

    //non ziplist lpush
    for (int i = 13; i < db.GetConfig().list_max_ziplist_entries + 100; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
        CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "lpush mylist failed");
        CHECK_FATAL(ctx.reply.integer != i + 1, "lpush mylist failed");
    }

    db.Call(ctx, del, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist value%d", i);
        db.Call(ctx, rpush, 0);
        CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "rpush mylist failed");
        CHECK_FATAL(ctx.reply.integer != i + 1, "rpush mylist failed");
    }
    RedisCommandFrame mrpush;
    mrpush.SetFullCommand("rpush mylist value10 value11 value12");
    db.Call(ctx, mrpush, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "rpush mylist failed");
    CHECK_FATAL(ctx.reply.integer != 13, "rpush mylist failed");

    //non ziplist lpush
    for (int i = 13; i < db.GetConfig().list_max_ziplist_entries + 100; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist value%d", i);
        db.Call(ctx, rpush, 0);
        CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "rpush mylist failed");
        CHECK_FATAL(ctx.reply.integer != i + 1, "rpush mylist failed");
    }
}
Esempio n. 8
0
void test_sequential_list(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);

    for (int i = 0; i < 10000; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist xvalue%d", i);
        db.Call(ctx, lpush, 0);
    }
    for (int i = 0; i < 10000; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist yvalue%d", i);
        db.Call(ctx, rpush, 0);
    }
    RedisCommandFrame index;
    index.SetFullCommand("lindex mylist 10001");
    uint64 start = get_current_epoch_millis();
    db.Call(ctx, index, 0);
    uint64 end = get_current_epoch_millis();
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "yvalue1", "lindex mylist failed");
    CHECK_FATAL((end - start) > 100, "lindex too slow for sequential list");

    RedisCommandFrame lrange;
    lrange.SetFullCommand("lrange mylist 10000 10005");
    start = get_current_epoch_millis();
    db.Call(ctx, lrange, 0);
    end = get_current_epoch_millis();
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_ARRAY, "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberSize() != 6, "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberAt(5).str != "yvalue5", "lrange mylist failed");
    CHECK_FATAL((end - start) > 100, "lrange too slow for sequential list");

}
Esempio n. 9
0
void test_lists_insert(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist value%d", i);
        db.Call(ctx, rpush, 0);
    }
    RedisCommandFrame insert;
    insert.SetFullCommand("linsert mylist before value3 valuexx");
    db.Call(ctx, insert, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "linsert mylist failed");
    CHECK_FATAL(ctx.reply.integer != 11, "linsert mylist failed");

    RedisCommandFrame index;
    index.SetFullCommand("lindex mylist 3");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "valuexx", "lindex mylist failed");

    //now list is not ziplist
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist xvalue%d", i);
        db.Call(ctx, rpush, 0);
    }
    insert.SetFullCommand("linsert mylist after xvalue3 valueyy");
    db.Call(ctx, insert, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_INTEGER, "linsert mylist failed");
    CHECK_FATAL(ctx.reply.integer != 22, "linsert mylist failed");
    index.SetFullCommand("lindex mylist 14");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "valueyy", "lindex mylist failed");
}
Esempio n. 10
0
void test_lists_lset(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    //ziplist push
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
    }
    RedisCommandFrame lset;
    lset.SetFullCommand("lset mylist 4 abcd");
    db.Call(ctx, lset, 0);
    RedisCommandFrame index;
    index.SetFullCommand("lindex mylist 4");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "abcd", "lindex mylist failed");

    //non ziplist lpush
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist xvalue%d", i);
        db.Call(ctx, lpush, 0);
    }
    lset.SetFullCommand("lset mylist -5 xxyy");
    db.Call(ctx, lset, 0);
    index.SetFullCommand("lindex mylist -5");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "xxyy", "lindex mylist failed");

}
Esempio n. 11
0
void test_lists_index(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
    }
    RedisCommandFrame index;
    index.SetFullCommand("lindex mylist 5");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "value4", "lindex mylist failed");
    index.SetFullCommand("lindex mylist 50");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_NIL, "lindex mylist failed");

    //now list is not ziplist
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame lpush;
        lpush.SetFullCommand("lpush mylist value%d", i);
        db.Call(ctx, lpush, 0);
    }
    index.SetFullCommand("lindex mylist 15");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_STRING, "lindex mylist failed");
    CHECK_FATAL(ctx.reply.str != "value4", "lindex mylist failed");
    index.SetFullCommand("lindex mylist 50");
    db.Call(ctx, index, 0);
    CHECK_FATAL(ctx.reply.type != REDIS_REPLY_NIL, "lindex mylist failed");
}
Esempio n. 12
0
void test_lists_lrange(Context& ctx, Ardb& db)
{
    db.GetConfig().list_max_ziplist_entries = 16;
    RedisCommandFrame del;
    del.SetFullCommand("del mylist");
    db.Call(ctx, del, 0);
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist value%d", i);
        db.Call(ctx, rpush, 0);
    }
    RedisCommandFrame lrange;
    lrange.SetFullCommand("lrange mylist 0 -1");
    db.Call(ctx, lrange, 0);
    CHECK_FATAL(ctx.reply.MemberSize() != 10, "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberAt(4).str != "value4", "lrange mylist failed");

    //now list is not ziplist
    for (int i = 0; i < 10; i++)
    {
        RedisCommandFrame rpush;
        rpush.SetFullCommand("rpush mylist xvalue%d", i);
        db.Call(ctx, rpush, 0);
    }
    lrange.SetFullCommand("lrange mylist 0 -1");
    db.Call(ctx, lrange, 0);
    CHECK_FATAL(ctx.reply.MemberSize() != 20, "lrange mylist failed");

    lrange.SetFullCommand("lrange mylist 10 12");
    db.Call(ctx, lrange, 0);
    CHECK_FATAL(ctx.reply.MemberSize() != 3, "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberAt(0).str != "xvalue0", "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberAt(1).str != "xvalue1", "lrange mylist failed");
    CHECK_FATAL(ctx.reply.MemberAt(2).str != "xvalue2", "lrange mylist failed");
}
Esempio n. 13
0
void test_bitset_common(Context& ctx, Ardb& db)
{
    RedisCommandFrame del;
    del.SetFullCommand("del mybitset mykey");
    db.Call(ctx, del, 0);

    RedisCommandFrame setbit;
    setbit.SetFullCommand("setbit mybitset 4011 1");
    db.Call(ctx, setbit, 0);
    CHECK_FATAL(ctx.reply.integer != 0, "setbit myzset failed");
    db.Call(ctx, setbit, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "setbit myzset failed");

    RedisCommandFrame getbit;
    getbit.SetFullCommand("getbit mybitset 4011");
    db.Call(ctx, getbit, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "getbit myzset failed");
    getbit.SetFullCommand("getbit mybitset 14011");
    db.Call(ctx, getbit, 0);
    CHECK_FATAL(ctx.reply.integer != 0, "getbit myzset failed");

    for (uint32 i = 0; i < 10; i++)
    {
        setbit.SetFullCommand("setbit mybitset %u 1", (i + 1) * 10000);
        db.Call(ctx, setbit, 0);
    }
    RedisCommandFrame bitcount;
    bitcount.SetFullCommand("bitcount mybitset 0 -1");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 11, "bitcount myzset failed");
    bitcount.SetFullCommand("bitcount mybitset 0 6250");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 6, "bitcount myzset failed");

    setbit.SetFullCommand("setbit mybitset %u 1", 1024 * 1024 * 9);
    db.Call(ctx, setbit, 0);
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 6, "bitcount myzset failed");
    bitcount.SetFullCommand("bitcount mybitset 0 -1");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 12, "bitcount myzset failed");

    RedisCommandFrame set;
    set.SetFullCommand("set mykey foobar");
    db.Call(ctx, set, 0);
    bitcount.SetFullCommand("bitcount mykey");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 26, "bitcount myzset failed");
    bitcount.SetFullCommand("bitcount mykey 0 0");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 4, "bitcount myzset failed");
    bitcount.SetFullCommand("bitcount mykey 1 1");
    db.Call(ctx, bitcount, 0);
    CHECK_FATAL(ctx.reply.integer != 6, "bitcount myzset failed");
}
Esempio n. 14
0
void test_keys_expire(Context& ctx, Ardb& db)
{
    RedisCommandFrame del;
    del.SetFullCommand("del mystring mylist myset myhash myzset mybitset");
    db.Call(ctx, del, 0);

    RedisCommandFrame set;
    set.SetFullCommand("set mystring 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("lpush mylist 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("hset myhash  f 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("zadd myzset 123 f");
    db.Call(ctx, set, 0);
    set.SetFullCommand("sadd myset 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("setbit mybitset 123 1");
    db.Call(ctx, set, 0);

    RedisCommandFrame expire;
    expire.SetFullCommand("expire mystring 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");
    expire.SetFullCommand("expire mylist 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");
    expire.SetFullCommand("expire myhash 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");
    expire.SetFullCommand("expire myzset 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");
    expire.SetFullCommand("expire myset 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");
    expire.SetFullCommand("expire mybitset 5");
    db.Call(ctx, expire, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "expire failed");

    RedisCommandFrame ttl;
    ttl.SetFullCommand("ttl mystring");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");
    ttl.SetFullCommand("ttl mylist");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");
    ttl.SetFullCommand("ttl myhash");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");
    ttl.SetFullCommand("ttl myset");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");
    ttl.SetFullCommand("ttl myzset");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");
    ttl.SetFullCommand("ttl mybitset");
    db.Call(ctx, ttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4 || ctx.reply.integer > 5, "ttl failed");

    RedisCommandFrame pttl;
    pttl.SetFullCommand("pttl mystring");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
    pttl.SetFullCommand("pttl mylist");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
    pttl.SetFullCommand("pttl myhash");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
    pttl.SetFullCommand("pttl myset");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
    pttl.SetFullCommand("pttl myzset");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
    pttl.SetFullCommand("pttl mybitset");
    db.Call(ctx, pttl, 0);
    CHECK_FATAL(ctx.reply.integer < 4000 || ctx.reply.integer > 5000, "ttl failed");
}
Esempio n. 15
0
void test_keys_rename(Context& ctx, Ardb& db)
{
    RedisCommandFrame del;
    del.SetFullCommand(
            "del mystring mylist myset myhash myzset mybitset mystring1 myset1 myhash1 mylist1 myset1 myzset1 mybitset1");
    db.Call(ctx, del, 0);
    RedisCommandFrame set;
    set.SetFullCommand("set mystring 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("lpush mylist 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("hset myhash  f 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("zadd myzset 123 f");
    db.Call(ctx, set, 0);
    set.SetFullCommand("sadd myset 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("setbit mybitset 123 1");
    db.Call(ctx, set, 0);

    RedisCommandFrame rename;
    rename.SetFullCommand("renamenx mystring mystring1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
    rename.SetFullCommand("renamenx myset myset1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
    rename.SetFullCommand("renamenx myhash myhash1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
    rename.SetFullCommand("renamenx mylist mylist1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
    rename.SetFullCommand("renamenx myzset myzset1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
    rename.SetFullCommand("renamenx mybitset mybitset1");
    db.Call(ctx, rename, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "rename failed");
}
Esempio n. 16
0
void test_keys_exists(Context& ctx, Ardb& db)
{
    RedisCommandFrame del;
    del.SetFullCommand("del mystring mylist myset myhash myzset mybitset");
    db.Call(ctx, del, 0);

    RedisCommandFrame exists;
    exists.SetFullCommand("exists mystring");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists mylist");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists myset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists myset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists myzset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists myhash");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");
    exists.SetFullCommand("exists mybitset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 0 || ctx.reply.type != REDIS_REPLY_INTEGER, "exists failed");

    RedisCommandFrame set;
    set.SetFullCommand("set mystring 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("lpush mylist 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("hset myhash  f 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("zadd myzset 123 f");
    db.Call(ctx, set, 0);
    set.SetFullCommand("sadd myset 123");
    db.Call(ctx, set, 0);
    set.SetFullCommand("setbit mybitset 123 1");
    db.Call(ctx, set, 0);
    exists.SetFullCommand("exists mystring");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists mylist");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists myset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists myset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists myzset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists myhash");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
    exists.SetFullCommand("exists mybitset");
    db.Call(ctx, exists, 0);
    CHECK_FATAL(ctx.reply.integer != 1, "exists failed");
}