MCPcopy Create free account
hub / github.com/acl-dev/acl / test_msetnx

Function test_msetnx

lib_acl_cpp/samples/redis/redis_string/redis_string.cpp:260–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260static bool test_msetnx(acl::redis_string& redis, int n)
261{
262 acl::string key1, key2, key3;
263 acl::string val1, val2, val3;
264 std::map<acl::string, acl::string> objs;
265 int ret;
266
267 for (int i = 0; i < n; i++)
268 {
269 key1.format("key1_%s_%d", __keypre.c_str(), i);
270 key2.format("key2_%s_%d", __keypre.c_str(), i);
271 key3.format("key3_%s_%d", __keypre.c_str(), i);
272
273 val1.format("val1_%s", key1.c_str());
274 val2.format("val2_%s", key2.c_str());
275 val3.format("val3_%s", key3.c_str());
276
277 objs[key1] = val1;
278 objs[key2] = val2;
279 objs[key3] = val3;
280
281 redis.clear();
282 ret = redis.msetnx(objs);
283 if (ret < 0)
284 {
285 printf("mset error: %s\r\n", redis.result_error());
286 return false;
287 }
288 else if (i < 10)
289 {
290 printf("msetnx ret: %d, %s=%s, %s=%s, %s=%s\r\n", ret,
291 key1.c_str(), val1.c_str(),
292 key2.c_str(), val2.c_str(),
293 key3.c_str(), val3.c_str());
294 }
295 objs.clear();
296 }
297
298 return true;
299}
300
301static bool test_setrange(acl::redis_string& redis, int n)
302{

Callers 1

mainFunction · 0.85

Calls 5

msetnxMethod · 0.80
result_errorMethod · 0.80
formatMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…