MCPcopy Create free account
hub / github.com/cinience/RedisStudio / DatabasesNum

Method DatabasesNum

RedisStudio/Redis/RedisClient.cpp:197–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197bool 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
230int RedisClient::DatabasesNum()
231{

Callers

nothing calls this directly

Calls 1

freeReplyObjectFunction · 0.85

Tested by

no test coverage detected