| 195 | } |
| 196 | |
| 197 | bool RedisClient::DatabasesNum(int& num) |
| 198 | { |
| 199 | bool retVal = false; |
| 200 | redisReply* reply = Command("config get databases"); |
| 201 | if (!reply) { |
| 202 | return retVal; |
| 203 | } |
| 204 | |
| 205 | if (reply->type == REDIS_REPLY_ARRAY && reply->elements>1 ) |
| 206 | { |
| 207 | retVal = true; |
| 208 | num = atoi(reply->element[1]->str); |
| 209 | freeReplyObject(reply); |
| 210 | } else { |
| 211 | freeReplyObject(reply); |
| 212 | for (int idx = 0; idx<16; ++idx) { |
| 213 | reply = Command("SELECT %d", idx); |
| 214 | if (!reply) return false; |
| 215 | |
| 216 | if (reply->type == REDIS_REPLY_STATUS) |
| 217 | { |
| 218 | retVal = true; |
| 219 | num = idx + 1; |
| 220 | freeReplyObject(reply); |
| 221 | } else { |
| 222 | freeReplyObject(reply); |
| 223 | break; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | return retVal; |
| 228 | } |
| 229 | |
| 230 | int RedisClient::DatabasesNum() |
| 231 | { |
nothing calls this directly
no test coverage detected