// File: /workspace/github_cpp_makefile_star2_O3/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 0x4370
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10857(%rip), %rsi     # 0x1400e
leaq 0x10856(%rip), %rdx     # 0x14014
leaq 0x148(%rsp), %rdi
callq 0x4370
leaq 0x188(%rsp), %rdi
callq 0xb5dc
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rdx
leaq 0x148(%rsp), %r8
movl $0x64, %esi
movl $0x18eb, %ecx           # imm = 0x18EB
callq 0xb6ea
testb %al, %al
je 0x4134
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 0xb9d2
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 0xb9d2
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x4158
leaq 0x220(%rsp), %rdi
movq %rax, %rsi
callq 0x443e
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1069e(%rip), %rsi     # 0x14045
leaq 0x1069c(%rip), %rdx     # 0x1404a
leaq 0xe0(%rsp), %rdi
callq 0x4370
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1067d(%rip), %rsi     # 0x1404b
leaq 0x10678(%rip), %rdx     # 0x1404d
leaq 0x78(%rsp), %rdi
callq 0x4370
leaq 0x220(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x5f8e
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 0x4370
leaq 0xe0(%rsp), %rdi
leaq 0x220(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x613e
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 0x4370
leaq 0x220(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x486c
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3afb
callq 0x3320
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xba94
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 0xb9d2
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x188(%rsp), %rdi
callq 0xbb54
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 0x443e
leaq 0x78(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x10409(%rip), %rsi     # 0x14072
leaq 0x10405(%rip), %rdx     # 0x14075
callq 0x4370
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x103bf(%rip), %rsi     # 0x14045
leaq 0x103bd(%rip), %rdx     # 0x1404a
leaq 0x30(%rsp), %rdi
callq 0x4370
leaq 0xe0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x5f8e
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 0x4370
leaq 0x78(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x613e
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 0x4370
leaq 0xe0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x486c
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x3dd9
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4820
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 0xb9d2
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x3ef2
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), %rax
leaq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x443e
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x10163(%rip), %rsi     # 0x14072
leaq 0x1015f(%rip), %rdx     # 0x14075
leaq 0x50(%rsp), %rdi
callq 0x4370
leaq 0x10(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x613e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x16093(%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 0x3f83
callq 0x3320
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x3f92
callq 0x3320
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xba94
movq 0x8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xba94
movq 0x1601b(%rip), %rdi     # 0x19fd8
leaq 0x10067(%rip), %rsi     # 0x1402b
movl $0xb, %edx
callq 0x33b0
movl 0x18c(%rsp), %esi
movq 0x15ffc(%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 0x15fc6(%rip), %rdi     # 0x19fd8
leaq 0x1001e(%rip), %rsi     # 0x14037
movl $0xd, %edx
callq 0x33b0
movl 0x1e8(%rsp), %esi
movq 0x15fa7(%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 0x1000a(%rip), %rsi     # 0x1408a
leaq 0x10004(%rip), %rdx     # 0x1408b
callq 0x4370
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4f20
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x40b2
callq 0x3320
leaq 0x50(%rsp), %rdi
callq 0x4326
leaq 0x78(%rsp), %rdi
callq 0x4470
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x40d5
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4470
leaq 0x220(%rsp), %rdi
callq 0x4470
leaq 0x188(%rsp), %rdi
callq 0xb618
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x410e
callq 0x3320
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x4120
callq 0x3320
xorl %eax, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x15e9d(%rip), %rdi     # 0x19fd8
leaq 0xfed3(%rip), %rsi      # 0x14015
movl $0x15, %edx
callq 0x33b0
movq 0x15e85(%rip), %rdi     # 0x19fd8
callq 0x31a0
xorl %edi, %edi
callq 0x33f0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x4176
callq 0x3320
jmp 0x4176
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4326
jmp 0x42aa
movq %rax, %rbx
jmp 0x4270
jmp 0x42a7
jmp 0x42bb
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
jne 0x41bf
jmp 0x42be
jmp 0x42bb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x42be
callq 0x3320
jmp 0x42be
jmp 0x42bb
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x41e5
callq 0x3320
jmp 0x41e5
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
jne 0x42c8
jmp 0x42cd
movq %rax, %rbx
jmp 0x42cd
jmp 0x42b6
jmp 0x422d
jmp 0x42b6
movq %rax, %rbx
jmp 0x4296
jmp 0x42b6
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x4230
callq 0x3320
jmp 0x4230
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
jne 0x42a0
jmp 0x42da
jmp 0x42b6
jmp 0x42e9
jmp 0x42e9
movq %rax, %rbx
jmp 0x42f9
movq %rax, %rbx
jmp 0x430b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x4270
callq 0x3320
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x42aa
callq 0x3320
jmp 0x42aa
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x4296
callq 0x3320
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x42da
callq 0x3320
jmp 0x42da
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x4470
jmp 0x42be
movq %rax, %rbx
jmp 0x42da
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x42cd
callq 0x3320
leaq 0xe0(%rsp), %rdi
callq 0x4470
leaq 0x220(%rsp), %rdi
callq 0x4470
jmp 0x42ec
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0xb618
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x430b
callq 0x3320
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x431d
callq 0x3320
movq %rbx, %rdi
callq 0x3550
nop