| 52 | } |
| 53 | |
| 54 | static bool test_setnx(acl::redis_string& redis, int n) |
| 55 | { |
| 56 | acl::string key; |
| 57 | acl::string value; |
| 58 | |
| 59 | for (int i = 0; i < n; i++) |
| 60 | { |
| 61 | key.format("%s_%d", __keypre.c_str(), i); |
| 62 | value.format("_setnx_%s", key.c_str()); |
| 63 | |
| 64 | redis.clear(); |
| 65 | int ret = redis.setnx(key.c_str(), value.c_str()); |
| 66 | if (ret < 0) |
| 67 | { |
| 68 | printf("setnx key: %s error: %s\r\n", |
| 69 | key.c_str(), redis.result_error()); |
| 70 | return false; |
| 71 | } |
| 72 | printf("%s: ret: %d, key: %s\r\n", __FUNCTION__, ret, |
| 73 | key.c_str()); |
| 74 | } |
| 75 | |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | static bool test_append(acl::redis_string& redis, int n) |
| 80 | { |