Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容 Redis 错误码规范 #382

Open
luky116 opened this issue Jul 24, 2024 · 1 comment
Open

兼容 Redis 错误码规范 #382

luky116 opened this issue Jul 24, 2024 · 1 comment
Assignees
Labels
☢️ Bug Something isn't working

Comments

@luky116
Copy link
Collaborator

luky116 commented Jul 24, 2024

Is this a regression?

Yes

Description

RESP 有特殊类型来处理错误。errors类型除了首字符是减号 '-'不是加号以外,其它跟简单字符串一样。RESP中简单字符和错误的真正区别是:错误被客户端当作异常处理,组成错误类型的字符串是错误消息自身。

基本格式如下:

"-Error message\r\n"

错误应答只在发生异常时发送,例如,要执行命令的参数数据类型不匹配或者命令不存在等。当收到错误返回时,客户端lib应该抛出一个异常。

错误返回例子:

-ERR unknown command 'foobar'
-WRONGTYPE Operation against a key holding the wrong kind of value

从"-"后面第一个单词起,直到第一个空格或者换行,表示返回的错误类型。这是Redis的一种约定,并不是RESP协议的要求。

ERR 是一个通用错误, 而 WRONGTYPE 是表示更具体的错误,意味着客户端在错误的数据类型上执行操作。这被叫做错误前缀(Error Prefix), 使客户端不用依赖具体错误消息就知道返回的错误类型,错误消息可能会随着时间而变化。

参考文档:https://redis.com.cn/topics/protocol.html

Please provide a link to a minimal reproduction of the bug

No response

Screenshots or videos

images

Please provide the version you discovered this bug in (check about page for version information)

No response

Anything else?

No response

@luky116 luky116 added the ☢️ Bug Something isn't working label Jul 24, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Compatible with Redis error code specifications

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️ Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants