| 29 | } |
| 30 | |
| 31 | static bool test_setex(acl::redis_string& redis, int n, int ttl) |
| 32 | { |
| 33 | acl::string key, value; |
| 34 | |
| 35 | for (int i = 0; i < n; i++) |
| 36 | { |
| 37 | key.format("%s_%d", __keypre.c_str(), i); |
| 38 | value.format("value_%s", key.c_str()); |
| 39 | |
| 40 | redis.clear(); |
| 41 | if (redis.setex(key.c_str(), value.c_str(), ttl) == false) |
| 42 | { |
| 43 | printf("setex key: %s error: %s\r\n", |
| 44 | key.c_str(), redis.result_error()); |
| 45 | return false; |
| 46 | } |
| 47 | else if (i < 10) |
| 48 | printf("setex key: %s, ttl: %d\r\n", key.c_str(), ttl); |
| 49 | } |
| 50 | |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | static bool test_setnx(acl::redis_string& redis, int n) |
| 55 | { |