当前位置:网站首页>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
边栏推荐
- 用 Table 在 SwiftUI 下创建表格
- Thrift 序列化协议浅析
- Metersphere -- Open Source continuous testing platform
- SwiftUI 的动画机制
- Swiftui 4.0's new navigation system
- Swiftui layout - size (bottom)
- 我正在使用中的博客创作工具
- 2022 melting welding and thermal cutting examination questions and online simulation examination
- 看了就会的 Rainbond 入门教程
- 【七夕】七夕孤寡小青蛙究极版?七夕节最终章!
猜你喜欢

How to effectively conduct the review meeting (Part 1)?

2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination

HCIP第十二天

Mobile phone scrolling screenshot software recommendation

国产数据库的红利还能“吃”多久?

2022 melting welding and thermal cutting examination questions and online simulation examination

Thoughts on the construction of some enterprise data platforms

Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions

Brief introduction and use of mqtt entry level

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
随机推荐
[Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!
Unittest executes runtestcase prompt <_ io. Textiowrapper name= '< stderr>' mode=W encoding=UTF-8 > solution
Iterator iterator interface
国产数据库的红利还能“吃”多久?
[ecmascript6] async and await
2022 melting welding and thermal cutting examination questions and online simulation examination
[线程安全问题] 多线程到底可能会带来哪些风险?
These three online PS tools should be tried
Create a table under swiftui with table
Core Data 是如何在 SQLite 中保存数据的
JS instantiation method
如何在 Core Data 中进行批量操作
js的实例化方式
Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?
SwiftUI 布局 —— 尺寸( 下 )
实时切换 Core Data 的云同步状态
ScottPlot入门教程:获取和显示鼠标处的数值
多线程顺序运行有几种方法?
基础架构之日志管理平台及钉钉&邮件告警通知
十、时间戳