当前位置: 首页 > wzjs >正文

乐至县建设局网站优化系统软件

乐至县建设局网站,优化系统软件,网站查外链,wap 网站 源码目录 Redis命令 通用命令 String Key的顶层格式 Hash List Set SortedSet Redis命令 通用命令 想知道某个命令怎么用 1.可以在官网学习用法 https://www.redis.net.cn/order/ 2. 使用 help命令 String Key的顶层格式 Hash List Set SortedSet 在IDEA使用Jedis操作…

目录

Redis命令

通用命令

String

Key的顶层格式

Hash

List

Set

SortedSet


Redis命令

通用命令

想知道某个命令怎么用

1.可以在官网学习用法

https://www.redis.net.cn/order/

2.  使用 help+命令

String

Key的顶层格式

Hash

List

Set

SortedSet

在IDEA使用Jedis操作Redis

常规使用

引入依赖

我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.leo</groupId><artifactId>jedis-work</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><name>jedis-work</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><junit.jupiter.version>5.7.0</junit.jupiter.version></properties><dependencies><!--jedis--><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>3.7.0</version></dependency><!--单元测试--><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.7.0</version><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.22.2</version><configuration><includes><include>**/*Test.java</include><include>**/*Tests.java</include></includes></configuration></plugin></plugins></build>
</project>

我的测试

package com.leo.test;import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import redis.clients.jedis.Jedis;
import org.junit.jupiter.api.Test;public class TestRedis {private Jedis jedis;@BeforeEachvoid setUp() {// 1.建立连接jedis = new Jedis("192.168.**.**", 6379);  //根据自己的ip// 2.设置密码jedis.auth("***");   自己的密码// 3.选择库jedis.select(0);}@Testvoid testString() {// 存入数据String result = jedis.set("name2", "大哥");System.out.println("result = " + result);// 获取数据String name = jedis.get("name2");System.out.println("name = " + name);}@AfterEachvoid tearDown() {if (jedis != null) {jedis.close();}}
}

Jedis的连接池

1.配置Jedis连接池工具类

package Utils;import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;public class JedisConnectionFactory {private static final JedisPool jedisPool;static {//配置连接池JedisPoolConfig poolConfig = new JedisPoolConfig();poolConfig.setMaxTotal(8);poolConfig.setMaxIdle(8);poolConfig.setMinIdle(0);poolConfig.setMaxWaitMillis(1000);//创建连接池对象jedisPool = new JedisPool(poolConfig,"192.168.88.134",6379,1000,"123321");}public static Jedis getJedis(){return jedisPool.getResource();}
}

建立连接使用工具类 

package com.leo.test;import Utils.JedisConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import redis.clients.jedis.Jedis;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.JedisFactory;
import redis.clients.jedis.JedisPool;public class TestRedis {private Jedis jedis;@BeforeEachvoid setUp() {// 1.建立连接//  方式1// jedis = new Jedis("192.168.88.134", 6379);//  方式2jedis= JedisConnectionFactory.getJedis();// 2.设置密码jedis.auth("123321");// 3.选择库jedis.select(0);}@Testvoid testString() {// 存入数据String result = jedis.set("name3", "小弟");System.out.println("result = " + result);// 获取数据String name = jedis.get("name3");System.out.println("name = " + name);}@AfterEachvoid tearDown() {if (jedis != null) {jedis.close();}}
}

http://www.dtcms.com/wzjs/87314.html

相关文章:

  • 可以做拟合的在线网站运营培训班有用吗
  • 个人备案可以做企业网站吗处理事件seo软件
  • web网站建设方案app制作一个需要多少钱
  • 微信公众号优惠劵网站怎么做的抖音seo排名优化公司
  • 怀柔住房和城乡建设委员会网站建站推广网站
  • 做网站公司南京软文代写平台
  • 金融电子商务网站建设知名网络软文推广平台
  • 什么是网站app建设怎么做一个网站
  • 网站支付接口如何做百度代发排名
  • 微信小程序网站建设方案常用的网络推广方法
  • 成都网站排名中国国家数据统计网
  • 做旅游攻略的网站代码设计一个简单的网页
  • 东莞市电池网站建设企业推广是什么意思
  • 网站备案办理头条今日头条新闻
  • 建设银行网站维修图片百度推广托管
  • 开网站建设个人如何做seo推广
  • 中国最大的网络公司排名南京seo优化公司
  • 紫金建设公司官网整站优化外包服务
  • 官网搭建 杭州seo视频网页入口网站推广
  • 网站建设项目确认书百度品牌专区
  • 网站开发技术现状百度推广培训机构
  • 怎么知道网站有没有做301重定向怎么把自己的网站发布到网上
  • 我做彩票网站开发彩票网站搭建百度站长资源平台
  • 中山智能设备网站建设最近的新闻热点
  • 给公司网站设计一元手游平台app
  • 做问卷比较好的网站手机创建网站免费注册
  • 好看的 网站后台模板搜索网站关键词
  • 佛山网站搭建最让顾客心动的促销活动
  • wordpress怎么用Redis快速seo关键词优化方案
  • 小米发布会ppt模板太原seo外包服务