5. redis管道, 发布订阅, 模拟队列
一. 发布订阅
#订阅scribe
127.0.0.1:6379> SUBSCRIBE "channel_1"
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "channel_1"
3) (integer) 1
1) "message"
2) "channel_1"
3) "haha"
1) "message"
2) "channel_1"
3) "hello world"
#发布消息publish
127.0.0.1:6379> publish "channel_1" haha
(integer) 1
127.0.0.1:6379> publish "channel_1" "hello world"
(integer) 1
二. 模拟队列
- 普通队列 : 对list进行lpush , rpop
- 优先级队列 :
brpop list1 list2 list3 timeout // 先从list1取,list1没有数据了再从list2取
三. pipline管道
- redis的管道相当于把多条命令批处理, 使原来多条命令需要多次连接服务器转为多条命令连接一次服务器
- pipline在命令行下没有,jedis有
/** pipline */
public void test3(){
Pipeline pipelined = jedis.pipelined();
for (int i = 0; i < 100; i++) {
pipelined.set("str"+i,i+"");
}
pipelined.sync(); // 提交管道
}
5. redis管道, 发布订阅, 模拟队列的更多相关文章
- 【springboot】【redis】springboot+redis实现发布订阅功能,实现redis的消息队列的功能
springboot+redis实现发布订阅功能,实现redis的消息队列的功能 参考:https://www.cnblogs.com/cx987514451/p/9529611.html 思考一个问 ...
- [翻译] C# 8.0 新特性 Redis基本使用及百亿数据量中的使用技巧分享(附视频地址及观看指南) 【由浅至深】redis 实现发布订阅的几种方式 .NET Core开发者的福音之玩转Redis的又一傻瓜式神器推荐
[翻译] C# 8.0 新特性 2018-11-13 17:04 by Rwing, 1179 阅读, 24 评论, 收藏, 编辑 原文: Building C# 8.0[译注:原文主标题如此,但内容 ...
- StackExchange.Redis 使用-发布订阅 (二)
使用Redis的发布订阅功能 redis另一个常见的用途是发布订阅功能 . 它非常的简单 ,当连接失败时 ConnectionMultiplexer 会自动重新进行订阅 . ISubscriber s ...
- spring boot 使用redis进行发布订阅
异步消息的方式有很多,这篇博客介绍如何使用redis进行发布订阅, 完成这个示例只需要三个文件 1.redis消息监听配置 @Configuration public class RedisListe ...
- redis的发布订阅、持久化存储、redis的主从复制
redis的发布订阅 1. 创建redis配置文件 vim /opt/redis_conf/reids-6379.conf mkdir /data/6379 redis-server redis-6 ...
- redis 实现发布订阅的功能
redis 除了作为缓存的功能外还可以用作消息中间件的功能,这片博客主要是介绍一下 redis 整合spring 实现消息的发布和订阅功能: 1:redis依赖,依赖两个包,redis 包, spri ...
- redis(3)发布订阅
一.发布/订阅模式 在软件工程里面,发布/订阅是一种消息模式,这种模式旨在将消息发送者和消息接收者解耦.发送者不需要关心将消息发送给谁,接收者也不需要知道消息的发送者是谁.发送者将消息发布以后就结束动 ...
- python之上下文管理、redis的发布订阅、rabbitmq
使用with打开文件的方式,是调用了上下文管理的功能 #打开文件的两种方法: f = open('a.txt','r') with open('a.txt','r') as f 实现使用with关闭s ...
- 【spring boot】【redis】spring boot 集成redis的发布订阅机制
一.简单介绍 1.redis的发布订阅功能,很简单. 消息发布者和消息订阅者互相不认得,也不关心对方有谁. 消息发布者,将消息发送给频道(channel). 然后是由 频道(channel)将消息发送 ...
随机推荐
- fedora22多媒体编码
sudo dnf install gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-ugly gstr ...
- Post和get乱码
post 在web.xml中添加 <filter> <filter-name>CharacterEncodingFilter</filter-name> <f ...
- 关于HTML的Element
今天搞HTML的时候,发现了一些操作element的方法.先引用一篇. 1.document.getElementById(id); 2.document.getElementByTagName(t ...
- makefile--目标搜索(八)
原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ 在一个较大的工程中,一般会将源代码和二进制文件(.o 文件和可执行文件)安排在不同的目录来进行区 ...
- 越狱Season 1-Season 1, Episode 3: Cell Test
Season 1, Episode 3: Cell Test -CO: Oh, my God. 我的天 Williamson, get in here. Williamson 快进来 What the ...
- Git错误non-fast-forward
Git错误non-fast-forward后的冲突解决 [日期:2012-04-21] 来源:Linux社区 作者:chain2012 [字体:大 中 小] 当要push代码到git时,出现提示 ...
- java 计算器基于工厂模式和功能单一模式
import java.util.Scanner; public class CaculationTest { public static void main(String[] args) { Sca ...
- HttpServletRequest/HttpServletResponse乱码问题解决
1.request.setCharacterEncoding只对POST请求起作用.GET请求用new String(paramterData.getBytes("iso8859-1&quo ...
- POI读取excel
HSSF是Horrible Spread Sheet Format的缩写 读取2007版本前 XSSF是XML Spread Sheet Format的缩写 读取2007版本后(包含2007)
- MMU讲解
MMU是Memory Management Unit的缩写,中文名是内存管理单元,它是中央处理器(CPU)中用来管理虚拟存储器.物理存储器的控制线路,同时也负责虚拟地址映射为物理地址,以及提供硬件机制 ...