| 7 | } |
| 8 | |
| 9 | bool RedisListModel::GetData( const std::string& key, RedisResult& results ) |
| 10 | { |
| 11 | bool retVal = false; |
| 12 | ScopedRedisReply lenreply = GetClient()->Command("LLEN %s", key.c_str()); |
| 13 | if (lenreply.IsNull()) |
| 14 | { |
| 15 | return false; |
| 16 | } |
| 17 | if (lenreply->type == REDIS_REPLY_INTEGER) |
| 18 | { |
| 19 | long long llen = lenreply->integer; |
| 20 | results.NewColumn("Value"); |
| 21 | for (int idx=0; idx<llen; ) |
| 22 | { |
| 23 | redisReply* reply = GetClient()->Command("LRANGE %s %d %d", key.c_str(), idx, idx+1000 > llen ? idx+1000 : llen - idx); |
| 24 | if (!reply) return retVal; |
| 25 | |
| 26 | if (reply->type == REDIS_REPLY_ARRAY) |
| 27 | { |
| 28 | std::size_t i = 0; |
| 29 | redisReply* tmpReply ; |
| 30 | while (i < reply->elements) |
| 31 | { |
| 32 | tmpReply = reply->element[i]; |
| 33 | results.NewRow(); |
| 34 | string& myvalue = results.Value(results.RowSize()-1, 0); |
| 35 | myvalue.assign(tmpReply->str, tmpReply->len); |
| 36 | i++; |
| 37 | } |
| 38 | retVal = true; |
| 39 | } |
| 40 | freeReplyObject(reply); |
| 41 | idx+=1000; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return retVal; |
| 46 | } |
| 47 | |
| 48 | bool RedisListModel::UpdateData( const std::string& key, |
| 49 | const std::string& oldValue, |