当前位置:网站首页>网络协议之:redis protocol详解
网络协议之:redis protocol详解
2022-06-25 22:11:00 【InfoQ】
简介
redis的高级用法
Redis中的pipline
(printf "INCR X\r\nINCR X\r\nINCR X\r\nINCR X\r\n"; sleep 1) | nc localhost 6379
:1
:2
:3
:4
Redis中的Pub/Sub
redis-cli -h 127.0.0.1
127.0.0.1:6379> subscribe topic
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "topic"
3) (integer) 1
redis-cli -h 127.0.0.1
127.0.0.1:6379> publish topic "what is your name?"
(integer) 1
1) "message"
2) "topic"
3) "what is your name?"
RESP protocol
Simple Strings
"+OK\r\n"
Bulk Strings
"$2\r\nok\r\n"
"$0\r\n\r\n"
"$-1\r\n"
RESP Integers
":18\r\n"
RESP Arrays
"*2\r\n$5\r\nredis\r\n$6\r\nserver\r\n"
"*3\r\n$5\r\nredis\r\n$6\r\nserver\r\n*1\r\n$4\r\ngood\r\n"
"*3\r\n
$5\r\nredis\r\n
$6\r\nserver\r\n
*1\r\n
$4\r\ngood\r\n"
RESP Errors
"-Err something wrong\r\n"
Inline commands
redis-cli -h 127.0.0.1
127.0.0.1:6379> get world
"hello"
telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get world
$5
hello
"*2\r\n$3\r\nget\r\n$5\r\nworld\r\n"
(printf "*2\r\n$3\r\nget\r\n$5\r\nworld\r\n"; sleep 1) | nc localhost 6379
-ERR Protocol error: expected '$', got ' '
$
(printf "*2\r\n\$3\r\nget\r\n\$5\r\nworld\r\n"; sleep 1) | nc localhost 6379
$5
hello
总结
边栏推荐
猜你喜欢
Leetcode 513. 找树左下角的值
STEP7主站与远程I/O组网_过路老熊_新浪博客
Uniapp -- the use of document collation and push of unipush
Alipay payment interface sandbox environment test and integration into an SSM e-commerce project
使用npm创建并发布包时遇到的常见问题
WINCC与STEP7的仿真连接_过路老熊_新浪博客
数组常用的一些操作方法
Database - mongodb
Unable to start debugging. Unexpected GDB output from command “-environment -cd xxx“ No such file or
解析產品開發失敗的5個根本原因
随机推荐
用frp搭建云电脑
The InputStream stream has been closed, but the file or folder cannot be deleted, indicating that it is occupied by the JVM
iomanip头文件在实战中的作用
Format the number. If the number is not enough, fill in 0, for example, 1:0001,25:0025
static关键字详解
JS中常用知识点
树莓派开机发送热点进行远程登录
Kotlin null pointer bug
剑指 Offer 48. 最长不含重复字符的子字符串
兆欧表电压档位选择_过路老熊_新浪博客
Two ways to center block level elements
请问可以不部署服务端实现图片上传吗?
Shredding Company poj 1416
博图软件中多重背景块的建立_过路老熊_新浪博客
Today's 61 Fu
mongodb
c_ uart_ interface_ Example and offboard modes
记录一下刷LeetCode瞬间有思路的一道简单题——剑指 Offer 09. 用两个栈实现队列
7.常用指令(下)v-on,v-bind,v-model的常见操作
Px4 simulation basis