drogonframework / drogonframework/drogon
在drogon/nosql/RedisResult.h中似乎有拼写错误
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 15
Description
在drogon/nosql/RedisResult.h中,可以看到
```
enum class RedisResultType
{
kInteger = 0,
kString,
kArray,
kStatus,
kNil, // 从语义上看似乎应该用kNull
kError
};
```
另外同一份文件中有
```
/**
* @brief return true if the result object is nil.
*
* @return true
* @return false
*/
bool isNil() const noexcept;
/**
* @brief Check if the result object is not nil.
*
* @return true
* @return false
*/
explicit operator bool() const
{
return !isNil();
}
```
这里用的是`kNil`、`isNil`
但是在中文文档
https://github.com/drogonframework/drogon-docs/blob/master/CHN-17-Redis.md
里面写的是:
```
redisClient->execCommandAsync(
[](const drogon::nosql::RedisResult &r) {
if (r.type() == RedisResultType::kNull) // 这里是kNull
LOG_INFO << "Cannot find variable associated with the key 'name'";
else
LOG_INFO << "Name is " << r.asString();
},
[](const std::exception &err) {
LOG_ERROR << "something failed!!! " << err.what();
},
"get name");
```
在英文版文档
https://github.com/drogonframework/drogon-docs/blob/master/ENG-17-Redis.md
里面却是
```
redisClient->execCommandAsync(
[](const drogon::nosql::RedisResult &r) {
if (r.type() == RedisResultType::kNil) // 这里是kNil
LOG_INFO << "Cannot find variable associated with the key 'name'";
else
LOG_INFO << "Name is " << r.asString();
},
[](const std::exception &err) {
LOG_ERROR << "something failed!!! " << err.what();
},
"get name");
```
在RedisResult.cc中,有两段代码,用的是`kNil`、`isNil`
```
RedisResultType RedisResult::type() const noexcept
{
switch (result_->type)
{
case REDIS_REPLY_STRING:
return RedisResultType::kString;
case REDIS_REPLY_ARRAY:
return RedisResultType::kArray;
case REDIS_REPLY_INTEGER:
return RedisResultType::kInteger;
case REDIS_REPLY_NIL:
return RedisResultType::kNil;
case REDIS_REPLY_STATUS:
return RedisResultType::kStatus;
case REDIS_REPLY_ERROR:
default:
return RedisResultType::kError;
}
}
```
```
bool RedisResult::isNil() const noexcept
{
return type() == RedisResultType::kNil;
}
```
也就是说,只有在中文文档中,才用`kNull`,其他各个文件用的都是`kNil`、`isNil`
但是从语义上看,应该是`kNull`、`isNull`
Contributor guide
Assessment
This issue has not been assessed yet.