// File: /workspace/github_cpp_makefile_star2_O1/Sherhang[P]redis-for-cpp/demo4.cpp
// Function: main
int main()
{   int pool_size = 100;
    string ip = "127.0.0.1";
    int port = 6379;
    string passwd ="yehang";
    RedisConnectPool rc_pool;
    if(!rc_pool.init(pool_size, ip, port, passwd))
    {
        cout<<"rc_pool init failure!"<<endl;
        exit(0);
    }
    
    //1
    cout<<"used num : "<<rc_pool.getUsedCount()<<endl;
    cout<<"canUse num : "<<rc_pool.getCanUseNum()<<endl;
    rc_pool.getConnect();
    
    //2
    cout<<"used num : "<<rc_pool.getUsedCount()<<endl;
    cout<<"canUse num : "<<rc_pool.getCanUseNum()<<endl;
    
    redisContext* context = rc_pool.getConnect();
    if(context == NULL)
        exit(0);
    Redis r1(context);
    r1.set("hello", "hi");
    cout<<r1.get("hello")<<endl;
    r1.del("hello");
    rc_pool.releaseConnect(context);//回收

    //3
    cout<<"used num : "<<rc_pool.getUsedCount()<<endl;
    cout<<"canUse num : "<<rc_pool.getCanUseNum()<<endl;
    context = rc_pool.getConnect();
    if(!rc_pool.isUseful(context))
    {
        cout<<"[ERROR] context is not in use "<<__func__<<__LINE__<<endl;
    }
    Redis redis(context);//初始化，这种方式会自动禁用disconnect
    redis.set("str", "hello");
    string v;
    v = redis.get("str");
    cout<<"get key "<<v<<endl;
    redis.del("str");
    redis.disconnect();//这句话无效
    //rc_pool.releaseConnect(context);//回收
    
    //4
    cout<<"used num : "<<rc_pool.getUsedCount()<<endl;
    cout<<"canUse num : "<<rc_pool.getCanUseNum()<<endl;
    context = rc_pool.getConnect();    
    if(context==NULL)
        cout<<"no context"<<endl;
    Redis redis1(context);
    cout<<redis1.get("str")<<endl;

    rc_pool.releaseConnect(context);
    rc_pool.releaseConnect(context);//重复回收
    
    //5
    cout<<"used num : "<<rc_pool.getUsedCount()<<endl;
    cout<<"canUse num : "<<rc_pool.getCanUseNum()<<endl;
    vector<string> vs;
    redis.keys("*",vs);
    //for(;;);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
leaq 0x178(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x10874(%rip), %rsi     # 0x14004
leaq 0x10876(%rip), %rdx     # 0x1400d
leaq 0x168(%rsp), %rdi
callq 0x4366
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10857(%rip), %rsi     # 0x1400e
leaq 0x10856(%rip), %rdx     # 0x14014
leaq 0x148(%rsp), %rdi
callq 0x4366
leaq 0x188(%rsp), %rdi
callq 0xb724
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rdx
leaq 0x148(%rsp), %r8
movl $0x64, %esi
movl $0x18eb, %ecx           # imm = 0x18EB
callq 0xb82e
testb %al, %al
je 0x4131
movq 0x167ca(%rip), %rdi     # 0x19fd8
leaq 0x10816(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x167ab(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x16775(%rip), %rdi     # 0x19fd8
leaq 0x107cd(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x16756(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
leaq 0x188(%rsp), %rdi
callq 0xbb12
movq 0x16713(%rip), %rdi     # 0x19fd8
leaq 0x1075f(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x166f4(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x166be(%rip), %rdi     # 0x19fd8
leaq 0x10716(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x1669f(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
leaq 0x188(%rsp), %rdi
callq 0xbb12
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x4155
leaq 0x220(%rsp), %rdi
movq %rax, %rsi
callq 0x442e
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1069e(%rip), %rsi     # 0x14045
leaq 0x1069c(%rip), %rdx     # 0x1404a
leaq 0xe0(%rsp), %rdi
callq 0x4366
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1067d(%rip), %rsi     # 0x1404b
leaq 0x10678(%rip), %rdx     # 0x1404d
leaq 0x78(%rsp), %rdi
callq 0x4366
leaq 0x220(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x5fd2
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x3a08
callq 0x3320
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3a1a
callq 0x3320
leaq 0x78(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x1061c(%rip), %rsi     # 0x14045
leaq 0x1061a(%rip), %rdx     # 0x1404a
callq 0x4366
leaq 0xe0(%rsp), %rdi
leaq 0x220(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x618e
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq 0x16572(%rip), %rdi     # 0x19fd8
callq 0x33b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3aa7
callq 0x3320
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x3ab6
callq 0x3320
leaq 0xe0(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x1057d(%rip), %rsi     # 0x14045
leaq 0x1057b(%rip), %rdx     # 0x1404a
callq 0x4366
leaq 0x220(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x485c
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3afb
callq 0x3320
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xbbd4
movq 0x164c4(%rip), %rdi     # 0x19fd8
leaq 0x10510(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x164a5(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x1646f(%rip), %rdi     # 0x19fd8
leaq 0x104c7(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x16450(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
leaq 0x188(%rsp), %rdi
callq 0xbb12
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x188(%rsp), %rdi
callq 0xbc9e
testb %al, %al
jne 0x3c48
movq 0x163f4(%rip), %rdi     # 0x19fd8
leaq 0x10463(%rip), %rsi     # 0x1404e
movl $0x1e, %edx
callq 0x33b0
movq 0x163dc(%rip), %rdi     # 0x19fd8
leaq 0x1046a(%rip), %rsi     # 0x1406d
movl $0x4, %edx
callq 0x33b0
movq 0x163c4(%rip), %rdi     # 0x19fd8
movl $0x32, %esi
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x8(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x442e
leaq 0x78(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x10409(%rip), %rsi     # 0x14072
leaq 0x10405(%rip), %rdx     # 0x14075
callq 0x4366
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x103bf(%rip), %rsi     # 0x14045
leaq 0x103bd(%rip), %rdx     # 0x1404a
leaq 0x30(%rsp), %rdi
callq 0x4366
leaq 0xe0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x5fd2
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x3cbd
callq 0x3320
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x3ccc
callq 0x3320
movq %r12, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
leaq 0x20(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x10383(%rip), %rsi     # 0x14072
leaq 0x1037f(%rip), %rdx     # 0x14075
leaq 0x10(%rsp), %rdi
callq 0x4366
leaq 0x78(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x618e
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x3400
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x3d36
callq 0x3320
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3d45
callq 0x3320
movq 0x1628c(%rip), %rdi     # 0x19fd8
leaq 0x10323(%rip), %rsi     # 0x14076
movl $0x8, %edx
callq 0x33b0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x1626a(%rip), %rdi     # 0x19fd8
callq 0x33b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
leaq 0x78(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x102c6(%rip), %rsi     # 0x14072
leaq 0x102c2(%rip), %rdx     # 0x14075
callq 0x4366
leaq 0xe0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x485c
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x3dd9
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4810
movq 0x161eb(%rip), %rdi     # 0x19fd8
leaq 0x10237(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x161cc(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x16196(%rip), %rdi     # 0x19fd8
leaq 0x101ee(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x16177(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
leaq 0x188(%rsp), %rdi
callq 0xbb12
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x3eed
movq 0x1612a(%rip), %rbx     # 0x19fd8
leaq 0x101ca(%rip), %rsi     # 0x1407f
movl $0xa, %edx
movq %rbx, %rdi
callq 0x33b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq 0x160f8(%rip), %rdi     # 0x19fd8
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x8(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x442e
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x10166(%rip), %rsi     # 0x14072
leaq 0x10162(%rip), %rdx     # 0x14075
leaq 0x50(%rsp), %rdi
callq 0x4366
leaq 0x10(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x618e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x16096(%rip), %rdi     # 0x19fd8
callq 0x33b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3f80
callq 0x3320
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x3f8f
callq 0x3320
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xbbd4
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xbbd4
movq 0x1601e(%rip), %rdi     # 0x19fd8
leaq 0x1006a(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x15fff(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
movq 0x15fc9(%rip), %rdi     # 0x19fd8
leaq 0x10021(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x15faa(%rip), %rdi     # 0x19fd8
callq 0x3530
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3260
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x10(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x1000d(%rip), %rsi     # 0x1408a
leaq 0x10007(%rip), %rdx     # 0x1408b
callq 0x4366
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4f1a
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x40af
callq 0x3320
leaq 0x50(%rsp), %rdi
callq 0x4322
leaq 0x78(%rsp), %rdi
callq 0x4460
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x40d2
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4460
leaq 0x220(%rsp), %rdi
callq 0x4460
leaq 0x188(%rsp), %rdi
callq 0xb760
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x410b
callq 0x3320
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x411d
callq 0x3320
xorl %eax, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x15ea0(%rip), %rdi     # 0x19fd8
leaq 0xfed6(%rip), %rsi      # 0x14015
movl $0x15, %edx
callq 0x33b0
movq 0x15e88(%rip), %rdi     # 0x19fd8
callq 0x31a0
xorl %edi, %edi
callq 0x33f0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x4173
callq 0x3320
jmp 0x4173
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4322
jmp 0x42a7
movq %rax, %rbx
jmp 0x426d
jmp 0x42a4
jmp 0x42b8
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
jne 0x41bc
jmp 0x42bb
jmp 0x42b8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x42bb
callq 0x3320
jmp 0x42bb
jmp 0x42b8
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x41e2
callq 0x3320
jmp 0x41e2
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
jne 0x42c5
jmp 0x42ca
movq %rax, %rbx
jmp 0x42ca
jmp 0x42b3
jmp 0x422a
jmp 0x42b3
movq %rax, %rbx
jmp 0x4293
jmp 0x42b3
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x422d
callq 0x3320
jmp 0x422d
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
jne 0x429d
jmp 0x42d7
jmp 0x42b3
jmp 0x42e6
jmp 0x42e6
movq %rax, %rbx
jmp 0x42f6
movq %rax, %rbx
jmp 0x4308
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x426d
callq 0x3320
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x42a7
callq 0x3320
jmp 0x42a7
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x4293
callq 0x3320
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x42d7
callq 0x3320
jmp 0x42d7
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x4460
jmp 0x42bb
movq %rax, %rbx
jmp 0x42d7
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x42ca
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4460
leaq 0x220(%rsp), %rdi
callq 0x4460
jmp 0x42e9
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0xb760
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x4308
callq 0x3320
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x431a
callq 0x3320
movq %rbx, %rdi
callq 0x3550