当前位置:网站首页>Redis学习笔记—客户端通讯协议RESP
Redis学习笔记—客户端通讯协议RESP
2022-06-23 09:00:00 【爱锅巴】
Redis制定了RESP(REdis Serialization Protocol,Redis序列化协议)实现客户端与服务端的正常交互,这种协议简单高效,既能够被机器解析,又容易被人类识别
发送命令格式
RESP的规定一条命令的格式如下,CRLF代表”\r\n”
*< 参数数量 > CRLF
$< 参数 1 的字节数量 > CRLF
< 参数 1> CRLF
...
$< 参数 N 的字节数量 > CRLF
< 参数 N> CRLF
以set hell world这条命令进行说明,参数数量为3个,因此第一行为:
*3
参数字节数分别是355,因此后面几行为:
$3
SET
$5
hello
$5
world
这样传输的格式就是:
*3\r\n$3\r\nSET\r\n$5\r\nhello\r\n$5\r\nworld\r\n
返回结果格式
Redis的返回结果类型分为以下五种:
- 状态回复:在RESP中第一个字节为”+”
- 错误回复:在RESP中第一个字节为”-“
- 整数回复:在RESP中第一个字节为”:”
- 字符串回复:在RESP中第一个字节为”$”
- 多条字符串回复:在RESP中第一个字节为”*”

边栏推荐
- An idea of using keep alive to cache data in vue3 form pages
- 523. Continuous Subarray Sum
- 自定义标签——jsp标签基础
- Subsets II of leetcode topic analysis
- (resolved) difference between leftmost prefix and overlay index
- 4、 Database design
- Leetcode topic analysis set matrix zeroes
- JSP入门总结
- Custom tags - JSP tag enhancements
- ARM中常见的英文解释
猜你喜欢

Custom tag - JSP tag Foundation

自定义标签——jsp标签增强

力扣之滑动窗口《循序渐进》(209.长度最小的子数组、904. 水果成篮)

Simple student management

'coach, I want to play basketball!'—— AI Learning Series booklet for system students

Testing -- automated testing selenium (about API)

Servlet-02 生命周期

297. Serialize and Deserialize Binary Tree

986. Interval List Intersections

Flink错误--Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered “time“
随机推荐
Jog运动模式
力扣之滑动窗口《循序渐进》(209.长度最小的子数组、904. 水果成篮)
JS mask important data of ID card and mobile phone number with * *
The fourth online workshop review
Can portals be the next decentraland?
MySQL fault case | mysqldump: couldn't execute 'select column_ NAME
What exactly is RT?
ucosii(学习笔记)
636. Exclusive Time of Functions
Intelligent operation and maintenance exploration | anomaly detection method in cloud system
[QNX Hypervisor 2.2用户手册]6.2 网络
4sum of leetcode topic analysis
Happy number of leetcode topic analysis
6月《中國數據庫行業分析報告》發布!智能風起,列存更生
Typora设置图片上传服务
Isomorphic strings for leetcode topic resolution
[qnx hypervisor 2.2 user manual]6.2 network
Detailed explanation of srl16e in xilinxffpga
Redis学习笔记—Redis与Lua
2022.6.22-----leetcode.513