| 271 | } |
| 272 | |
| 273 | Status LocalRedis::GetModelVersion(int64_t* full_version, |
| 274 | int64_t* latest_version) { |
| 275 | std::string cmd("GET model_version"); |
| 276 | redisReply* reply = (redisReply *)redisCommand(c_, cmd.c_str()); |
| 277 | if (REDIS_REPLY_NIL == reply->type) { |
| 278 | *full_version = -1; |
| 279 | *latest_version = -1; |
| 280 | } else if (REDIS_REPLY_STRING == reply->type) { |
| 281 | std::string str(reply->str); |
| 282 | if (str.find(",") == std::string::npos) { |
| 283 | freeReplyObject(reply); |
| 284 | return Status(error::Code::INTERNAL, |
| 285 | "[Redis] Parse model_version failed. " + |
| 286 | std::string(reply->str)); |
| 287 | } |
| 288 | auto offset = str.find(","); |
| 289 | *full_version = atoll(str.substr(0, offset).c_str()); |
| 290 | *latest_version = atoll(str.substr(offset+1).c_str()); |
| 291 | } else { |
| 292 | freeReplyObject(reply); |
| 293 | return Status(error::Code::INTERNAL, |
| 294 | "[Redis] run redisCommand-Get model_version failed. " + |
| 295 | std::string(reply->str)); |
| 296 | } |
| 297 | freeReplyObject(reply); |
| 298 | |
| 299 | return Status::OK(); |
| 300 | } |
| 301 | |
| 302 | Status LocalRedis::SetModelVersion(int64_t full_version, |
| 303 | int64_t latest_version) { |