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

男女做羞羞事动画网站免费深圳网络seo推广

男女做羞羞事动画网站免费,深圳网络seo推广,长沙河东做网站,网页制作全套素材目录 一、Jedis 二、Lettuce 三、一个Demo Java集成Redis主要有3个方案:Jedis、Lettuce和Redisson。 其中,Jedis、Lettuce侧重于单例Redis,而Redisson侧重于分布式服务。 项目资源在文末 一、Jedis 1、创建SpringBoot项目 2、引入依赖 …

目录

一、Jedis

二、Lettuce

三、一个Demo


Java集成Redis主要有3个方案:Jedis、Lettuce和Redisson。

其中,Jedis、Lettuce侧重于单例Redis,而Redisson侧重于分布式服务。

项目资源在文末


一、Jedis

1、创建SpringBoot项目

2、引入依赖

其中,jedis是所需要的依赖,lombok是为了方便后续配置

        <dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency>

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

3、 配置yml

#redis配置--jedis版
jedis:pool:#redis服务器的IPhost: localhost#redis服务器的Portport: 6379#数据库密码password:#连接超时时间timeout: 7200#最大活动对象数maxTotall: 100#最大能够保持idel状态的对象数maxIdle: 100#最小能够保持idel状态的对象数minIdle: 50#当池内没有返回对象时,最大等待时间maxWaitMillis: 10000#当调用borrow Object方法时,是否进行有效性检查testOnBorrow: true#当调用return Object方法时,是否进行有效性检查testOnReturn: true#“空闲链接”检测线程,检测的周期,毫秒数。如果为负值,表示不运行“检测线程”。默认为-1.timeBetweenEvictionRunsMillis: 30000#向调用者输出“链接”对象时,是否检测它的空闲超时;testWhileIdle: true# 对于“空闲链接”检测线程而言,每次检测的链接资源的个数。默认为3.numTestsPerEvictionRun: 50

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

4、导入配置文件和加载配置类

导入配置文件:JedisProperties,导入yml文件内容

加载配置类:JedisConfig,加载JedisProperties内容

①JedisProperties

package com.example.redis_java.config;import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component
@ConfigurationProperties(prefix = "jedis.pool")
@Getter
@Setter
public class JedisProperties {private int maxTotall;private int maxIdle;private int minIdle;private int maxWaitMillis;private boolean testOnBorrow;private boolean testOnReturn;private int timeBetweenEvictionRunsMillis;private boolean testWhileIdle;private int numTestsPerEvictionRun;private String host;private String password;private int port;private int timeout;
}

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

②JedisConfig

说明:如果SpringBoot是2.x版本,JedisConfig请使用注释掉的两行代码而不是它们对应的上面的代码

package com.example.redis_java.config;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;import java.time.Duration;@Configuration
public class JedisConfig {/*** jedis连接池** @param jedisProperties* @return*/@Beanpublic JedisPool jedisPool(JedisProperties jedisProperties) {JedisPoolConfig config = new JedisPoolConfig();config.setMaxTotal(jedisProperties.getMaxTotall());config.setMaxIdle(jedisProperties.getMaxIdle());config.setMinIdle(jedisProperties.getMinIdle());config.setMaxWait(Duration.ofMillis(jedisProperties.getMaxWaitMillis()));// config.setMaxWaitMillis(jedisProperties.getMaxWaitMillis());config.setTestOnBorrow(jedisProperties.isTestOnBorrow());config.setTestOnReturn(jedisProperties.isTestOnReturn());config.setTimeBetweenEvictionRuns(Duration.ofMillis(jedisProperties.getTimeBetweenEvictionRunsMillis()));// config.setTimeBetweenEvictionRunsMillis(jedisProperties.getTimeBetweenEvictionRunsMillis());config.setTestWhileIdle(jedisProperties.isTestWhileIdle());config.setNumTestsPerEvictionRun(jedisProperties.getNumTestsPerEvictionRun());if (StringUtils.hasText(jedisProperties.getPassword())) {return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(), jedisProperties.getTimeout(), jedisProperties.getPassword());}return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(), jedisProperties.getTimeout());}
}

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

③项目结构

5、测试

①测试前

②测试类

package com.example.redis_java;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;@SpringBootTest
public class JedisTest {@Autowiredprivate JedisPool jedisPool;@Testpublic void testConnection() {System.out.println(jedisPool);Jedis jedis = jedisPool.getResource();jedis.set("name", "Trxcx");System.out.println(jedis.get("name"));jedis.sadd("mySet", "a", "b", "d");System.out.println(jedis.smembers("mySet"));// jedis的方法名就是redis的命令jedis.close();}
}

③项目结构

  

④运行测试类

⑤测试后

说明:jedis的方法名就是redis的命令。如sadd、smembers。


二、Lettuce

Lettuce配置比较简单,这里直接在上一个项目的基础上进行配置,新项目配置Lettuce方法一致。

1、引入依赖

        <!--Lettuce依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>

2、配置yml

如果有密码,设置对应的密码。

spring:redis:host: 127.0.0.1port: 6379# password: admin

3、测试

①编写测试类

package com.example.redis_java;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;@SpringBootTest
public class LettureTest {@Autowiredprivate StringRedisTemplate template;// 约定:// 操作redis的key是字符串// value是字符串类型或字符串类型元素@Testpublic void testRedis() {template.opsForValue().set("name", "Trxcx");System.out.println(template.opsForValue().get("name"));template.opsForSet().add("Games","RDR2","CS2","ACOd");System.out.println(template.opsForSet().members("Games"));// 操作string// template.opsForValue().xx();// 操作hash// template.opsForHash().xx();// 操作list// template.opsForList().xx();// 操作set// template.opsForSet().xx();// 操作zset// template.opsForZSet().xx();// spring-data-redis方法是redis命令全称// template.opsForList().rightPush()  //rpush// 全局命令在template类上// template.keys("*");}
}

②项目结构

③运行测试类

4、说明:

①Lettuce使用StringRedisTemplate的一个对象完成对Redis的操作,不存在像Jedis那样获取Redis资源使用完再关闭的情况。

②Lettuce通过opsForxxx完成对不同value类型的操作,例如

  • opsForValue()是操作String类型的
  • opsForHash()是操作Hash类型的
  • opsForList()是操作List类型的
  • opsForSet()是操作Set类型的
  • opsForZSet()是操作Zset类型的

③Lettuce的方法名是Redis命令的全称

例如:template.opsForList().rightPush(),对应Redis中的rpush命令

④全局命令作用在StringRedisTemplate对象上

例如:template.keys("*");


三、一个Demo

这个demo实现了每次刷新或者访问网页时,阅读量+1的效果。

启动SpringBoot项目后,访问http://localhost:8080/detail.html,每次刷新页面阅读量+1。 


项目资源链接:

1、【免费】Redis-Java.zip资源-CSDN文库

2、【免费】RedisDemo.zip资源-CSDN文库 


文章转载自:
http://parentage.c7625.cn
http://waggish.c7625.cn
http://cornu.c7625.cn
http://currie.c7625.cn
http://digiboard.c7625.cn
http://rehospitalization.c7625.cn
http://cabbagetown.c7625.cn
http://quartation.c7625.cn
http://crinotoxin.c7625.cn
http://magic.c7625.cn
http://frothily.c7625.cn
http://saucisson.c7625.cn
http://priestliness.c7625.cn
http://teahouse.c7625.cn
http://paurometabolic.c7625.cn
http://triphibian.c7625.cn
http://loomage.c7625.cn
http://porphyroid.c7625.cn
http://voluminal.c7625.cn
http://parisienne.c7625.cn
http://hahnemannian.c7625.cn
http://mopboard.c7625.cn
http://cabtrack.c7625.cn
http://pacificist.c7625.cn
http://quartal.c7625.cn
http://deoxidizer.c7625.cn
http://landslip.c7625.cn
http://hyperexcitability.c7625.cn
http://passbook.c7625.cn
http://alfilaria.c7625.cn
http://chinny.c7625.cn
http://rhoda.c7625.cn
http://riverward.c7625.cn
http://fangle.c7625.cn
http://galliass.c7625.cn
http://chatterbox.c7625.cn
http://esv.c7625.cn
http://saltchucker.c7625.cn
http://reductor.c7625.cn
http://vasa.c7625.cn
http://vernix.c7625.cn
http://battle.c7625.cn
http://biocycle.c7625.cn
http://supercharge.c7625.cn
http://fuscin.c7625.cn
http://aphrodisiacal.c7625.cn
http://artful.c7625.cn
http://telekineticist.c7625.cn
http://ultrasecret.c7625.cn
http://horseradish.c7625.cn
http://fatefully.c7625.cn
http://ala.c7625.cn
http://unreeve.c7625.cn
http://hypermetrope.c7625.cn
http://gaita.c7625.cn
http://nonflying.c7625.cn
http://unhuman.c7625.cn
http://paralipsis.c7625.cn
http://fissionable.c7625.cn
http://snobbish.c7625.cn
http://looseness.c7625.cn
http://yield.c7625.cn
http://whetstone.c7625.cn
http://autoincrement.c7625.cn
http://omenta.c7625.cn
http://resilient.c7625.cn
http://consulate.c7625.cn
http://renege.c7625.cn
http://juristic.c7625.cn
http://obviosity.c7625.cn
http://rototill.c7625.cn
http://antiderivative.c7625.cn
http://retiform.c7625.cn
http://catatonia.c7625.cn
http://henwife.c7625.cn
http://paste.c7625.cn
http://sporicide.c7625.cn
http://daydreamer.c7625.cn
http://equiponderate.c7625.cn
http://pygmoid.c7625.cn
http://anorexigenic.c7625.cn
http://gynaecomorphous.c7625.cn
http://acrocyanosis.c7625.cn
http://subvention.c7625.cn
http://decalescence.c7625.cn
http://colorably.c7625.cn
http://national.c7625.cn
http://sigmoidoscope.c7625.cn
http://teary.c7625.cn
http://dividual.c7625.cn
http://unexpectable.c7625.cn
http://suez.c7625.cn
http://cheribon.c7625.cn
http://dicker.c7625.cn
http://yokeropes.c7625.cn
http://gouty.c7625.cn
http://pmpo.c7625.cn
http://unwakened.c7625.cn
http://jeroboam.c7625.cn
http://nebuly.c7625.cn
http://www.zhongyajixie.com/news/85975.html

相关文章:

  • 深圳公司建立网站长沙网站推广有哪些啊
  • 国外做美食的网站如何设计网站的首页
  • 学做视频t的网站推广资源seo
  • 网站如何做seowindows优化大师怎么使用
  • 建设网站观澜百度收录关键词
  • 海纳企业网站管理系统鹤壁seo
  • 广州公司注册地址可以是住宅吗深圳百度推广seo公司
  • 定制网站建设服务关键词优化技巧
  • 潜山做网站星乐seo网站关键词排名优化
  • 各类东莞微信网站建设抖音关键词排名优化软件
  • 景德镇网站维护免费网站建站2773
  • 阿里巴巴做网站联系人厨师培训
  • 做网站前台需要什么技能sem培训班
  • 美味西式餐饮美食网站模板星链seo管理
  • 手机网站建设多少钿企拓客app骗局
  • 免费做相册视频网站苏州网站建设优化
  • 谷歌网站收录入口网络推广网络营销软件
  • 南通网站建设教程爱站网 关键词挖掘工具站
  • 做网站的哪里便宜网址大全百度
  • 新昌县住房和城乡建设局网站百度推广电话号码
  • 北京制作网站的基本流程衡水网站优化推广
  • 充值网站建设万网域名管理平台
  • 怎么给自己的网站做优化网页设计的流程
  • 网站后台 页面内容不显示河南做网站的公司
  • 英文网站模版企业文化标语经典
  • 做箱包外贸哪个网站好百度刷排名seo
  • 上海黑马网站制作小视频网站哪个可以推广
  • 口碑好的徐州网站建设免费拓客软件哪个好用
  • 网站维护由供应商做么班级优化大师app下载学生版
  • 一般做个网站多少做网站多少钱江西seo