当前位置:网站首页>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
边栏推荐
- Hcip day 11
- Create a table under swiftui with table
- 58子站安居,经纪人营销管理平台登录接口加密逆向
- Node file operation
- Iterator iterator interface
- HCIP第十天
- How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
- 多线程顺序运行有几种方法?
- @Solution to DS ('slave') multi data source compatible transaction problem
- Redis-配置文件讲解
猜你喜欢

It's so hot that solar power can't take off? Hello, head

八、picker用法 下拉框选择效果

【七夕】七夕孤寡小青蛙究极版?七夕节最终章!

The method of implementing simple student achievement management system with C language

TDengine 助力西门子轻量级数字化解决方案
![[ecmascript6] set and map](/img/64/dd6ffc5f0faf881b990e609cf62343.png)
[ecmascript6] set and map

linux安装mysql

Brief introduction and use of mqtt entry level

How to reduce the resolution of only 3D camera but not UI camera
Some problems encountered in the development of Excel VBA, solutions, and continuous updates
随机推荐
C# 获取当前路径7种方法
Many "double first-class" universities have launched the research guarantee and prediction name!
九、uni-popup用法 下拉框底部弹窗效果
Node文件操作
Swiftui layout - size (top)
Redis-Redis在Jedis中的使用
如何在 Core Data 中进行批量操作
文件批量重命名工具Bulk Rename Utility
SwiftUI 的动画机制
Penguin side: why not recommend using select *?
When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash
Raspberry pie foundation | summarize and record some operations in the learning process of raspberry pie
卡方分布和伽马函数(Chi-Square Distribution)
2022低压电工考试题及答案
力扣解法汇总1331-数组序号转换
国产数据库的红利还能“吃”多久?
Swiftui 4.0's new navigation system
BGP experiment
The method of implementing simple student achievement management system with C language
Excel VBA 免密查看VBE加密代码