当前位置:网站首页>Redis发布订阅和数据类型
Redis发布订阅和数据类型
2022-08-03 11:06:00 【程程呀是小白】
目录
运行错误(解决办法为3 4)connect timed out

本文是本人以前笔记,如果说是在掘金上看到的话没错,还是本人程程呀 的个人主页 - 动态 - 掘金只有这一个。如果有哪里不对的话欢迎各位大佬指出问题,本人是一个小白。
上一篇文章链接为:Redis类型_程程呀是小白的博客-CSDN博客 ,本篇是连接上一篇文章Redis类型_程程呀是小白的博客-CSDN博客 的。
如果是springboot的话请看springboot创建项目_程程呀是小白的博客-CSDN博客_springboot创建项目 ,这个是从头开始的还没有学完springboot,一起学习呀!!!!
Redis发布订阅
Redis发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息
Redis客户端可以订阅任意数量的频道
新数据类型
1新数据类型BITMAPS
Setbit<key><offset><value>设置bitmaps中某个偏移的值(0或1)
Getbit<key><offset>获取bitmaps中某个偏移的值
Bitcount<key>[start end]统计字符串从start字节到end字节比特值为1的数量
Bitop and(or/not/xor)<destkey>[key...]bitop是一个复合操作,他可以多个bitmaps的and(交集),or(并集),not(非),xor(异或)操作并将结果保存在destkey中。
bitop and unique:users:and:20201104_03 unique:users:20201103 unique:users:20201104
(integer) 2
2新数据类型hyperloglog(基数的计算)
Pfadd<key><element>[element...]添加指定元素到hyperloglog
Pfcount<key>[key...]计算HLL近似值
Pfmerge<destkey><sourcekey>[sourcekey...]将一个或者多个HLL合并后结果存储在另一个HLL中
3新数据类型geospatial
Geoadd<key><longitude><latitude><member>[longitude latitude member...]添加地理位置(经度,维度,名称)
Geopos<key><member>[member...]获取指定地区的坐标值
Geodist<key><member1><member2>[m|km|ft|mi]获取两个位置之间的直线距离
Georadius<key><longitude><latitude>radius m|km|ft|mi 以给定的经纬度为中心。
测试
1jedis所需要的jar包
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
2模拟测试
public static void main(String[] args) {
//创建jedis对象
Jedis jedis=new Jedis("192.168.1.6",6379);
//测试
String value= jedis.ping();
System.out.println(value);
}
运行错误(解决办法为3 4)connect timed out
public static void main(String[] args) {
//创建jedis对象
Jedis jedis=new Jedis("192.168.1.6",6379);
//测试
String value= jedis.ping();
System.out.println(value);
}
能够正确运行
PONG
3 查看/关闭防火墙
[[email protected] ccy]# Systemctl status firewalld 查看是否关闭
[[email protected] ccy]# systemctl stop firewalld 关闭
4 将保护模式protected-mode 为no
[[email protected] ccy]# cd /usr/local/bin
[[email protected] bin]# ./redis-cli
127.0.0.1:6379> config get protected-mode
1) "protected-mode"
2) "yes"
127.0.0.1:6379> config set protected-mode no
OK
127.0.0.1:6379> config get protected-mode
1) "protected-mode"
2) "no" 
本文是本人以前笔记,如果说是在掘金上看到的话没错,还是本人程程呀 的个人主页 - 动态 - 掘金只有这一个。如果有哪里不对的话欢迎各位大佬指出问题,本人是一个小白。
上一篇文章链接为:Redis类型_程程呀是小白的博客-CSDN博客 ,本篇是连接上一篇文章Redis类型_程程呀是小白的博客-CSDN博客 的。
如果是springboot的话请看springboot创建项目_程程呀是小白的博客-CSDN博客_springboot创建项目 ,这个是从头开始的还没有学完springboot,一起学习呀!!!!
边栏推荐
猜你喜欢
随机推荐
Lease recovery system based on PHP7.2+MySQL5.7
MATLAB Programming and Applications 2.6 Strings
LeetCode 899 有序队列[字典序] HERODING的LeetCode之路
一文带你弄懂 CDN 技术的原理
Dva.js 新手入门指南
LP流动性挖矿DAPP系统开发丨流动性挖矿功能原理及说明
2022年五面蚂蚁、三面拼多多、字节跳动最终拿offer入职拼多多
STM32入门开发 介绍SPI总线、读写W25Q64(FLASH)(硬件+模拟时序)
MySQL之json数据操作
LyScript implements memory stack scanning
Skills required to be a good architect: How to draw a system architecture that everyone will love?What's the secret?Come and open this article to see it!...
SAP 电商云 Spartacus UI 的 External Routes 设计明细
【TypeScript】为什么要选择 TypeScript?
MySQL数据库实战(1)
浅谈SVN备份
Basic using MySQL database
Binary search tree (search binary tree) simulation implementation (there is a recursive version)
笔试题:金额拆分
图新地球为什么很模糊,白球、看图、下载问题深度剖析
混动产品谁更吃香,看技术还是看市场?








