当前位置:网站首页>Basic use of jedis
Basic use of jedis
2022-04-22 00:53:00 【RB_ VER】
jedis It's using java To operate redis Middleware .
First create maven project , Import jedis rely on .
public static void main(String[] args) {
// 1. establish Jedis object
Jedis jedis = new Jedis("127.0.0.1", 6379);
// jedis All the way is redis All the orders of
// Test link
System.out.println(jedis.ping());
}
jedis Part of API Example :
// Empty data
jedis.flushDB();
// Determine whether a key exists
jedis.exists("k1");
// Add key value pair
jedis.set("k1","v1");
// All key value pairs in the system
Set<String> set = jedis.keys("*");
// Delete key
jedis.del("k1");
// The type of judgment value
jedis.type("k2");
// Returns the data in all current databases key Number of
jedis.dbSize();
jedis Implementing transaction
public static void main(String[] args) {
// 1. establish Jedis object
Jedis jedis = new Jedis("127.0.0.1", 6379);
// Open transaction
Transaction multi = jedis.multi();
try{
multi.set("k1","v1");
multi.exec();
} catch(Exception e) {
multi.discard();
} finally {
jedis.close();
}
}
版权声明
本文为[RB_ VER]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211712126722.html
边栏推荐
猜你喜欢

解决 idea web项目没有小蓝点的问题

24张图攻克border-image

环形链表1和2双指针详解

Structure of actual combat training module III

How to set the validity period of win11 account password? Win11 account password usage period setting tutorial

跨链桥漏洞总结

Memory management

Redis (III): redis Cluster - master-slave replication, sentinel and cluster

logstash导入movielens测试数据

Flattening multilevel bidirectional linked list-c language
随机推荐
程序员怎么个人接单?
HMS Core 6.4.0版本发布公告
软件测试的目的,为什么要做软件测试?
Knock stupid l1-059
Introduction to microservices, euraka, ribbon, openfeign
【微服务】(八)—— Eureka 平滑迁移 Nacos 方案
R-Dropout
ROZRZ在线测量自动测量在线刀补CNC远程刀补机床远程刀联对刀仪远程刀补扫码传输刀补
linuix cat指令
Redis (III): redis Cluster - master-slave replication, sentinel and cluster
【面试普通人VS高手系列】能谈一下CAS机制吗?
数字化时代,企业运维面临现状及挑战分析解读
[opencv actual combat] beauty mode, open: is the beauty function so powerful? (demons dancing. JPG)
logstash导入movielens测试数据
Hackathon大赛进行时,快来看看这份指南
Distributed transactions and Seata
Mobile Internet app development, byte beating, JD 360 Netease interview questions sorting
Binary search method
See how the project manager brings a project to ruin
R-Dropout