错误的EntityNotFound来自Store Layer Redis Golang
我有一个Golang项目,该项目将REDIS
实现为后端商店。在存储层的GET
方法中,我想检查实体是否存在。如果实体存在现有,我将返回否则,我有两种情况:
- 错误
entitynotfound
- db错误,
我只能返回DB错误。我如何返回未找到错误的实体。就像在redis
中检查的条件是什么。
请帮助
I have a golang Project that implements redis
as it's backend store. In the Get
method of the store layer, I want to check if an entity is existing or not. If the entity is existing i will return it else i have two cases :
- Error
EntityNotFound
- DB Error
I am only able to return the DB Error. How can i return the entity not found error. Like what's the condition for checking in redis
.
Help Please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行密钥查找时,REDIS客户端将返回错误,如果键不存在。您可以检查该错误是否等于
redis.nil
,这表明找不到键。When doing a key lookup the Redis client will return an error if the key does not exist. You can check if that error is equal to
redis.Nil
, which indicates that the key was not found.