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

Method GetData

RedisStudio/Redis/RedisHashModel.cpp:9–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7}
8
9bool RedisHashModel::GetData( const std::string& key, RedisResult& results )
10{
11 bool retVal = false;
12 redisReply* reply = GetClient()->Command("HKEYS %s", key.c_str());
13 if (!reply) return retVal;
14 results.NewColumn("Field ");
15 results.NewColumn("Value");
16 if (reply->type == REDIS_REPLY_ARRAY)
17 {
18 std::size_t i = 0;
19 redisReply* tmpReply ;
20 bool isOK = true;
21 while (i < reply->elements)
22 {
23 tmpReply = reply->element[i];
24 redisReply* theReply = GetClient()->Command("HGET %s %s", key.c_str(), tmpReply->str);
25 if (!theReply) break;
26 if (theReply->type != REDIS_REPLY_STRING)
27 {
28 isOK = false;
29 freeReplyObject(theReply);
30 break;
31 }
32 results.NewRow();
33
34 string& myFiled = results.Value(results.RowSize()-1, 0) ;
35 myFiled.assign(tmpReply->str, tmpReply->len);
36
37 string& myvalue = results.Value(results.RowSize()-1, 1) ;
38 myvalue.assign(theReply->str, theReply->len);
39 freeReplyObject(theReply);
40 i++;
41 }
42 if (isOK)
43 retVal = true;
44 }
45 freeReplyObject(reply);
46 return retVal;
47}
48
49bool RedisHashModel::UpdateData( const std::string& key,
50 const std::string& oldValue,

Callers

nothing calls this directly

Calls 6

freeReplyObjectFunction · 0.85
CommandMethod · 0.80
NewColumnMethod · 0.80
NewRowMethod · 0.80
ValueMethod · 0.80
RowSizeMethod · 0.80

Tested by

no test coverage detected