mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-03 04:17:52 +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);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
delete value[i];
|
||||
delete [] value[i];
|
||||
|
||||
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);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
delete value[i];
|
||||
delete [] value[i];
|
||||
|
||||
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);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
delete value[i];
|
||||
delete [] value[i];
|
||||
|
||||
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);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
delete values[i];
|
||||
delete [] values[i];
|
||||
|
||||
delete [] values;
|
||||
|
||||
@ -274,7 +274,7 @@ static bool test_rpush4(acl::redis_list &redis, int n)
|
||||
{
|
||||
const char *value = values.back();
|
||||
values.pop_back();
|
||||
delete value;
|
||||
delete [] value;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -301,7 +301,7 @@ static bool test_rpush5(acl::redis_list &redis, int n)
|
||||
{
|
||||
const char *value = values.back();
|
||||
values.pop_back();
|
||||
delete value;
|
||||
delete [] value;
|
||||
}
|
||||
|
||||
return ret > 0 ? true : false;
|
||||
@ -702,6 +702,7 @@ static void usage(const char* procname)
|
||||
"-I rw_timeout[default: 10]\r\n"
|
||||
"-S [if slice request, default: no]\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",
|
||||
procname);
|
||||
}
|
||||
@ -709,12 +710,12 @@ static void usage(const char* procname)
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
@ -739,6 +740,9 @@ int main(int argc, char* argv[])
|
||||
case 'c':
|
||||
cluster_mode = true;
|
||||
break;
|
||||
case 'p':
|
||||
passwd = optarg;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -751,6 +755,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
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