当前位置:网站首页>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中第一个字节为”*”

边栏推荐
猜你喜欢

Jog运动模式

In depth interpretation of poca smart contract platform gear: the road to parallel architecture public chain

Redis学习笔记—持久化机制之RDB
【NanoPi2试用体验】裸机第一步

3. Caller 服务调用 - dapr

【活动报名】SOFAStack × CSDN 联合举办开源系列 Meetup ,6 月 24 日火热开启

三层架构与SSM之间的对应关系

Testing -- automated testing selenium (about API)

Servlet-02 生命周期

Mysql 数据库入门总结
随机推荐
Combination sum II of leetcode topic analysis
In depth interpretation of poca smart contract platform gear: the road to parallel architecture public chain
【学习资源】理解数学和热爱数学
[QNX Hypervisor 2.2用户手册]6.2 网络
'coach, I want to play basketball!'—— AI Learning Series booklet for system students
C#之Lambda不得不说的用法
(resolved) difference between leftmost prefix and overlay index
6、 Web Architecture Design
MySQL fault case | mysqldump: couldn't execute 'select column_ NAME
设CPU有16根地址线,8根数据线,并用MREQ作为访存控制线号......存储器与CPU的连接
Restore the default routing settings of the primary network card
[QNX Hypervisor 2.2用户手册]6.1 使用QNX Hypervisor系统
Leetcode topic analysis set matrix zeroes
36氪首发|云原生数据库公司「拓数派」完成新一轮战略融资,估值已达准独角兽级别
Geoserver添加mongoDB数据源
力扣之滑动窗口《循序渐进》(209.长度最小的子数组、904. 水果成篮)
Utilisation du cookie du module de demande de noeud
在小程序中实现视频通话及互动直播的一种方法
MySQL故障案例 | mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME
文件的打开新建与存储