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

免费一键网站seo关键词排名技术

免费一键网站,seo关键词排名技术,自建站是属于什么模式,手机端店铺装修在前面说的JedisSentinelPool只能实现主从的切换&#xff0c;而无法实现读写的分离。 1.哨兵的客户端实现主从切换方案 <dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</arti…

在前面说的JedisSentinelPool只能实现主从的切换,而无法实现读写的分离

1.哨兵的客户端实现主从切换方案
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/redis.clients/jedis --><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>3.6.3</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
# Redis哨兵服务器地址
redis.sentinel=aliyun:26885,aliyun:26886,aliyun:26887
redis.master=mymaster
# Redis服务器连接密码(默认为空)
redis.password=null
redis.timeout=30000
# 连接池最大连接数(使用负值表示没有限制)
redis.maxTotal=30
# 连接池中的最大空闲连接
redis.maxIdle=10
redis.numTestsPerEvictionRun=1024
redis.timeBetweenEvictionRunsMillis=30000
redis.minEvictableIdleTimeMillis=1800000
redis.softMinEvictableIdleTimeMillis=10000
# 连接池最大阻塞等待时间(使用负值表示没有限制)
redis.maxWaitMillis=1500
redis.testOnBorrow=true
redis.testWhileIdle=true
redis.blockWhenExhausted=false
redis.JmxEnabled=true
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;import java.util.HashSet;
import java.util.Set;@Configuration
@PropertySource("classpath:application.properties")
public class RedisSentinelConfig {@Value("${redis.sentinel}")private String hosts;@Value("${redis.master}")private String master;@Value("${redis.timeout}")private int timeout;@Value("${redis.maxIdle}")private int maxIdle;@Value("${redis.maxWaitMillis}")private int maxWaitMillis;@Value("${redis.blockWhenExhausted}")private Boolean blockWhenExhausted;@Value("${redis.JmxEnabled}")private Boolean JmxEnabled;@Beanpublic JedisPoolConfig  jedisPoolConfigFactory() {JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();jedisPoolConfig.setMaxIdle(maxIdle);jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);// 连接耗尽时是否阻塞, false报异常,true阻塞直到超时, 默认truejedisPoolConfig.setBlockWhenExhausted(blockWhenExhausted);// 是否启用pool的jmx管理功能, 默认truejedisPoolConfig.setJmxEnabled(JmxEnabled);jedisPoolConfig.setTestOnBorrow(true);jedisPoolConfig.setTestOnReturn(true);return jedisPoolConfig;}@Beanpublic JedisSentinelPool JedisSentinelPoolFactory(JedisPoolConfig jedisPoolConfig){Set<String> nodeSet = new HashSet<>();//获取到节点信息String nodeString = hosts;//判断字符串是否为空if(nodeString == null || "".equals(nodeString)){throw new RuntimeException("RedisSentinelConfiguration initialize error nodeString is null");}String[] nodeArray = nodeString.split(",");//判断是否为空if(nodeArray == null || nodeArray.length == 0){throw new RuntimeException("RedisSentinelConfiguration initialize error nodeArray is null");}//循环注入至Set中for(String node : nodeArray){System.out.println("Read node : "+node);nodeSet.add(node);}//创建连接池对象JedisSentinelPool jedisSentinelPool = new JedisSentinelPool(master,nodeSet,jedisPoolConfig ,timeout);return jedisSentinelPool;}}
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisSentinelPool;/*** 操作字符串类型*/
@Component
public class RedisString {public final static String RS_STR_NS = "rs:";@Autowiredprivate JedisSentinelPool jedisSentinelPool;/*** 向Redis中存值,永久有效*/public String set(String key, String value) {Jedis jedis = null;try {jedis = jedisSentinelPool.getResource();return jedis.set(RS_STR_NS +key, value);} catch (Exception e) {throw new RuntimeException("向Redis中存值失败!");} finally {jedis.close();}}/*** 批量向Redis中存值,永久有效*/public String msetRaw(String... keysvalues) {Jedis jedis = null;try {jedis = jedisSentinelPool.getResource();return jedis.mset(keysvalues);} catch (Exception e) {throw new RuntimeException("批量向Redis中存值失败!");} finally {jedis.close();}}/*** 根据传入Key获取指定Value*/public String get(String key) {Jedis jedis = null;try {jedis = jedisSentinelPool.getResource();return jedis.get(RS_STR_NS +key);} catch (Exception e) {throw new RuntimeException("获取Redis值失败!");} finally {jedis.close();}}}
2、读写分离的实现

需要自己去封装代码实现。
待补充

http://www.ds6.com.cn/news/70944.html

相关文章:

  • 江西省建设招标网站如何做网站优化
  • 后台网站怎么做视频一起来看在线观看免费
  • 盐城网站建设网站制作推广廊坊今日头条新闻
  • 婚纱摄影网站排名开鲁视频
  • 重庆南岸营销型网站建设公司哪家专业设计网站排行榜前十名
  • 周口哪里有做网站的网上做广告推广
  • 网站收录大幅度下降大型门户网站建设
  • 微商城网站建设多少钱制作网页app
  • 做网站哪个软件好用灰色词快速排名方法
  • 凡科建站好用吗营销网站建设门户
  • 知乎怎么做自己网站推广产品百度在线识图
  • 邢台专业网站建设公司推荐外包优化网站
  • 网站推广途径选择今日新闻播报
  • 网络推广有哪些网站最佳的资源搜索引擎
  • 网站开发网页上传和网页发布网络推广培训班哪家好
  • 福州电子网站建设广州网站建设方案维护
  • 用django怎么做网站厦门网站搜索引擎优化
  • 什么样的网站需要认证怎么开展网络营销推广
  • 个人博客网站html模板手机系统优化工具
  • 昆明网站建设 技术支持微信crm客户管理系统
  • wex5 后端实现全网站开发上海关键词优化方法
  • 教做西餐的网站搭建网站平台需要多少钱
  • 做网站需要会写代码吗写文章一篇30元兼职
  • 唐山网站建设找煌途百度下载官方下载安装
  • 牛商网网站做seo好么免费seo培训
  • 网站制作费用及后期运营营销网站建设网站开发
  • 做外贸有哪些好的网站有哪些内容青岛seo
  • p2vr做的网站上传网络媒体推广报价
  • 万江做网站收录网站查询
  • 做公益的网站有哪些广东广州网点快速网站建设