当前位置:网站首页>Redis redis use in jedis
Redis redis use in jedis
2022-07-28 14:44:00 【Although the sunset is not as beautiful as you】
Preface
I won't post Baidu's conceptual solutions , Simply speaking ,Jedis yes Redis Officially recommended Java Connect development tools ! Although the present SpringBoot2.× The version has already Jedis Instead of Lettuce, But I think it's still necessary to know Jedis Use !
1. How to be in java Integration in the project Jedis And connect Redis database ?
① Create a Maven project

② Import Jedis and fastjson rely on , Wait patiently for the download to complete !
<!-- Import jedis My bag -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.2.0</version>
</dependency>
<!--fastjson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
③ Connect Redis test , Here for the convenience of testing , The connection is local Redis service , Connecting to the remote requires changing the configuration file and turning off the firewall , In the future, I will write a separate article to introduce this !
// 1、 new Jedis Object can
Jedis jedis = new Jedis("127.0.0.1",6379);
// jedis All commands are all our previous commands
System.out.println(jedis.ping());
Pictured :

return PONG, Prove that the connection was successful !
④ frequently-used API practice :
// 1、 new Jedis Object can
Jedis jedis = new Jedis("127.0.0.1",6379);
jedis.flushDB();// Clear all data in the current library
jedis.set("name","dingyongjun");
jedis.set("age","23");
jedis.set("high","173");
System.out.println("name:"+jedis.get("name")+"\nage:"+jedis.get("age")+"\nhigh"+jedis.get("high"));
Pictured :

jedis.lpush("list","1","2","3","4");
System.out.println("list: "+jedis.lrange("list",0,-1));

⑤ summary : stay Jedis Middle connection use Redis, and Redis Console commands are completely consistent
边栏推荐
- [ecmascript6] proxy and reflection
- FormData对象的使用, var formdata=new FormData()
- Some problems encountered in the development of Excel VBA, solutions, and continuous updates
- C语言中浮点数据类型(你学废了吗)
- pix2pix
- Chi square distribution and gamma function
- It's so hot that solar power can't take off? Hello, head
- How to effectively conduct the review meeting (Part 1)?
- 2022 low voltage electrician examination questions and answers
- 分集技术简略
猜你喜欢

Hcip day 10

@DS('slave') 多数据源兼容事务问题解决方案

Minitest -- applet automation testing framework

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it

围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育

Redis-配置文件讲解

如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然

看了就会的 Rainbond 入门教程
C # read INI file and key value pair operation

2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination
随机推荐
How to use the C language library function getchar ()
BGP experiment
Tdengine helps Siemens' lightweight digital solutions
Iterator iterator interface
pix2pix
2022高处安装、维护、拆除考试题库及在线模拟考试
爆肝整理JVM十大模块知识点总结,不信你还不懂
js的实例化方式
Added the ability of class @published for @cloudstorage
Many "double first-class" universities have launched the research guarantee and prediction name!
@Solution to DS ('slave') multi data source compatible transaction problem
Redis-Redis在Jedis中的使用
Animation mechanism of swiftui
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
C语言实现简单学生成绩管理系统的方法
如何只降3D相机不降UI相机的分辨率
Hand in hand from 0 to a "Nuggets special attention" Google plug-in, 5000 words detailed vue3 responsive principle, the advantages, disadvantages and choices of several cache read-write schemes, flyin
ScottPlot入门教程:获取和显示鼠标处的数值
数字化转型安全问题频发,山石网科助力数字政府建设
文件批量重命名工具Bulk Rename Utility