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

Function test_setnx

lib_acl_cpp/samples/redis/redis_string/redis_string.cpp:54–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static 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
79static bool test_append(acl::redis_string& redis, int n)
80{

Callers 1

mainFunction · 0.85

Calls 5

setnxMethod · 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…