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

如何做转运网站黄聪 wordpress

如何做转运网站,黄聪 wordpress,产品造型设计,商城系统网站模板文章目录 前言一、 springboot 版本二、引入 redis 依赖三、增加配置文件四、增加配置类1、 RedissonConfig2、RedisConfig 五、增加操作类#xff0c;主要操作 string 总结 前言 一、 springboot 版本 spring-boot.version2.3.5.RELEASE/spring-boot.version主要操作 string 总结 前言 一、 springboot 版本 spring-boot.version2.3.5.RELEASE/spring-boot.versiondependencyManagementdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-dependencies/artifactIdversion${spring-boot.version}/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagement二、引入 redis 依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId/dependency三、增加配置文件 spring:redis:cluster:nodes: 192.168.162.235:6379,192.168.162.235:6380,192.168.162.235:6381,192.168.162.235:6382,192.168.162.235:6383,192.168.162.235:6384max-redirects: 3pool:#最大空闲连接max-idle: 8#最小空闲连接min-idle: 0#最大连接数-1表示是没有限制max-active: 8#最大阻塞等待时间-1表示没有限制max-wait: -1#连接超时时间毫秒timeout: 60000commandTimeout: 5000password: 123456connectionTimeout: 60000四、增加配置类 1、 RedissonConfig Configuration public class RedissonConfig {Value(${spring.redis.cluster.nodes})private String[] nodes;Value(${spring.redis.password})private String password;Value(${spring.redis.connectionTimeout})private int connectionTimeout;Bean(destroyMethod shutdown)public RedissonClient redissonClient() {Config config new Config();ClusterServersConfig clusterServersConfig config.useClusterServers();clusterServersConfig.addNodeAddress(Stream.of(nodes).map((node) - redis:// node).toArray(String[]::new)).setConnectTimeout(connectionTimeout);if (StringUtils.isNotBlank(password)) {clusterServersConfig.setPassword(password);}return Redisson.create(config);} }2、RedisConfig Configuration public class RedisConfig {BeanConditionalOnMissingBean(name redisTemplate)public RedisTemplateString, Object redisTemplate(RedisConnectionFactory factory) {RedisTemplateString, Object template new RedisTemplate();// 配置连接工厂template.setConnectionFactory(factory);//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值默认使用JDK的序列化方式Jackson2JsonRedisSerializer jacksonSeial new Jackson2JsonRedisSerializer(Object.class);ObjectMapper om new ObjectMapper();// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和publicom.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会跑出异常// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);jacksonSeial.setObjectMapper(om);// 值采用json序列化template.setValueSerializer(jacksonSeial);//使用StringRedisSerializer来序列化和反序列化redis的key值template.setKeySerializer(new StringRedisSerializer());// 设置hash key 和value序列化模式template.setHashKeySerializer(new StringRedisSerializer());template.setHashValueSerializer(jacksonSeial);template.afterPropertiesSet();return template;}BeanConditionalOnMissingBean(StringRedisTemplate.class)public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {StringRedisTemplate template new StringRedisTemplate();template.setConnectionFactory(redisConnectionFactory);return template;} }五、增加操作类主要操作 string Setter Service public class StringRedisTemplateClient {Resourceprivate StringRedisTemplate stringRedisTemplate;/*** 已废弃不兼容低版本的spring-data-redis*/Deprecatedpublic Boolean expire(String key, Integer seconds) {Boolean succeedstringRedisTemplate.expire(key, Duration.ofSeconds(seconds));return succeed;}/*** 单独key的过期时间*/public Boolean expire(String key, long timeout, TimeUnit unit) {Boolean succeedstringRedisTemplate.expire(key, timeout,unit);return succeed;}//get,set,setex,需要调用方自己序列化valuepublic String get(String key) {String valuestringRedisTemplate.opsForValue().get(key);return value;}public void set(String key, String value, long timeout, TimeUnit unit) {stringRedisTemplate.opsForValue().set(key, value, timeout, unit);}public void set(String key, String value) {stringRedisTemplate.opsForValue().set(key, value);}//对象或泛型版的 set,setex,get。不用自己手动序列化public void set(String key, Object value) {String jsonStr JSONObject.toJSONString(value);set(key,jsonStr);}public void setex(String key, String value, Integer seconds) {stringRedisTemplate.opsForValue().set(key, value, Duration.ofSeconds(seconds));}public void setex(String key, String value, Long seconds) {stringRedisTemplate.opsForValue().set(key, value, Duration.ofSeconds(seconds));}public void setex(String key, Object value, Integer seconds) {String jsonStr JSONObject.toJSONString(value);setex(key,jsonStr,seconds);}public long ttl(String key) {Long expiresIn stringRedisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);return expiresIn;}public T T get(String key, ClassT clazz) {String jsonStr get(key);return JSONObject.parseObject(jsonStr, clazz);}public T ListT getList(String key, ClassT clazz) {String jsonStr get(key);return JSONObject.parseArray(jsonStr, clazz);}/*** 检查某个key是否存在* param key* return*/public boolean exist(String key) {String value get(key);return StringUtils.isNotBlank(value);}public Boolean delete(String key) {Boolean succeedstringRedisTemplate.delete(key);return succeed;}public Long incr(String key) {Long increment stringRedisTemplate.opsForValue().increment(key);return increment;} }总结
http://www.zqtcl.cn/news/576258/

相关文章:

  • 怎么把做的网站发布长春建网站
  • 织梦网站手机端郑州网站制作公司名单
  • 如何建设网站安全网站桥页也叫
  • 南浔网站建设昆山智能网站开发
  • 阿里云可以做电商网站吗杭州网站建设浙江
  • 查询网站备案进度网站建设推广
  • 怎么做公司网站需要什么科目高端网站建设教学
  • 资讯平台网站模板中企中立做的网站好吗
  • 网站开发人员配备山西省吕梁市简介
  • 网站注销主体注销中国建设教育协会培训报名网站
  • 电商网站设计思想建设化妆品网站的成本
  • 做房产网站能赚钱吗深圳龙华区邮政编码
  • 网站开发素材代码手机网站 win8风格
  • 免费推广网站软件班级网站怎么做ppt模板
  • 在线做任务的网站有哪些wordpress ui 插件
  • 竣工验收备案表查询网站优化大师win10能用吗
  • php 网站管理系统做生鲜管理系统的网站
  • 昆山建设工程招聘信息网站业绩显示屏 东莞网站建设技术支持
  • 百度我的网站广东广州网站建设
  • 怎么提高网站流量沈阳有资质做网站的公司有哪些
  • 内蒙古住房与城乡建设厅网站网址微信可以上网
  • 如何网站seo中国化工第九建设公司网站
  • 无锡网站推广优化公司单位网站建设必要性
  • 网站建设丶金手指花总12网站建设是怎么挣钱
  • 网站开发都是用什么框架广西建设网人员查询网
  • 做购物网站怎么写开题报告中山如何建网站
  • 专门做游戏交易的网站新网站如何才做被百度收录
  • 网站模板打包自己做电视视频网站吗
  • seo网站关键词排名提升公司建设网站需要多少钱
  • 湖北网站设计流程旺旺食品有限公司网页设计