mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-03 20:38:11 +08:00
fixed bugs in redis_list demo
This commit is contained in:
parent
6385c33c81
commit
995ed8ae06
@ -62,7 +62,7 @@ static bool test_lpush2(acl::redis_list& redis, int n)
|
|||||||
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
delete value[i];
|
delete [] value[i];
|
||||||
|
|
||||||
delete [] value;
|
delete [] value;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ static bool test_lpush4(acl::redis_list &redis, int n)
|
|||||||
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
delete value[i];
|
delete [] value[i];
|
||||||
|
|
||||||
delete [] value;
|
delete [] value;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ static bool test_lpush5(acl::redis_list &redis, int n)
|
|||||||
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
delete value[i];
|
delete [] value[i];
|
||||||
|
|
||||||
delete [] value;
|
delete [] value;
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ static bool test_lpush6(acl::redis_list &redis, int n)
|
|||||||
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
printf("lpush key:%s ret : %d ok\r\n", __key, ret);
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
delete values[i];
|
delete [] values[i];
|
||||||
|
|
||||||
delete [] values;
|
delete [] values;
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ static bool test_rpush4(acl::redis_list &redis, int n)
|
|||||||
{
|
{
|
||||||
const char *value = values.back();
|
const char *value = values.back();
|
||||||
values.pop_back();
|
values.pop_back();
|
||||||
delete value;
|
delete [] value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -301,7 +301,7 @@ static bool test_rpush5(acl::redis_list &redis, int n)
|
|||||||
{
|
{
|
||||||
const char *value = values.back();
|
const char *value = values.back();
|
||||||
values.pop_back();
|
values.pop_back();
|
||||||
delete value;
|
delete [] value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret > 0 ? true : false;
|
return ret > 0 ? true : false;
|
||||||
@ -702,6 +702,7 @@ static void usage(const char* procname)
|
|||||||
"-I rw_timeout[default: 10]\r\n"
|
"-I rw_timeout[default: 10]\r\n"
|
||||||
"-S [if slice request, default: no]\r\n"
|
"-S [if slice request, default: no]\r\n"
|
||||||
"-c [use cluster mode]\r\n"
|
"-c [use cluster mode]\r\n"
|
||||||
|
"-p passwd[default: empty]\r\n"
|
||||||
"-a cmd[lpush|rpush|lpushx|rpushx|lrange|rpop|lpop|blpop|brpop|rpoplpush|brpoplpush|lrem|ltrim|llen|lindex|lset|linsert_before|linsert_after]\r\n",
|
"-a cmd[lpush|rpush|lpushx|rpushx|lrange|rpop|lpop|blpop|brpop|rpoplpush|brpoplpush|lrem|ltrim|llen|lindex|lset|linsert_before|linsert_after]\r\n",
|
||||||
procname);
|
procname);
|
||||||
}
|
}
|
||||||
@ -709,12 +710,12 @@ static void usage(const char* procname)
|
|||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int ch, n = 50, conn_timeout = 10, rw_timeout = 10;
|
int ch, n = 50, conn_timeout = 10, rw_timeout = 10;
|
||||||
acl::string addr("127.0.0.1:6379"), cmd("all");
|
acl::string addr("127.0.0.1:6379"), cmd("all"), passwd;
|
||||||
bool cluster_mode = false;
|
bool cluster_mode = false;
|
||||||
|
|
||||||
acl::log::stdout_open(true);
|
acl::log::stdout_open(true);
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0)
|
while ((ch = getopt(argc, argv, "hs:n:C:T:a:cp:")) > 0)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
@ -739,6 +740,9 @@ int main(int argc, char* argv[])
|
|||||||
case 'c':
|
case 'c':
|
||||||
cluster_mode = true;
|
cluster_mode = true;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
passwd = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -751,6 +755,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);
|
acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);
|
||||||
|
|
||||||
|
if (!passwd.empty())
|
||||||
|
{
|
||||||
|
cluster.set_password("default", passwd);
|
||||||
|
client.set_password(passwd);
|
||||||
|
}
|
||||||
|
|
||||||
acl::redis_list redis(&client);
|
acl::redis_list redis(&client);
|
||||||
|
|
||||||
if (cluster_mode)
|
if (cluster_mode)
|
||||||
|
6
lib_acl_cpp/samples/redis/redis_list/valgrind.sh
Normal file → Executable file
6
lib_acl_cpp/samples/redis/redis_list/valgrind.sh
Normal file → Executable file
@ -1,3 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
valgrind --tool=memcheck --leak-check=yes -v ./redis_list -s 127.0.0.1:6379 -a all -n 10
|
valgrind --tool=memcheck --leak-check=yes -v ./redis_list -s 127.0.0.1:6379 -n 1000 -c -a lpush
|
||||||
|
echo "enter any key to continue"
|
||||||
|
read n
|
||||||
|
valgrind --tool=memcheck --leak-check=yes -v ./redis_list -s 127.0.0.1:6379 -n 1000 -c -a lrange
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user