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

网站建设哪家更专业软件开发公司组织结构图

网站建设哪家更专业,软件开发公司组织结构图,旅游网模板html代码,莱芜四中网站#x1f3ac; 艳艳耶✌️#xff1a;个人主页 #x1f525; 个人专栏 #xff1a;《Spring与Mybatis集成整合》《Vue.js使用》 ⛺️ 越努力 #xff0c;越幸运。 1.Redis与SSM的整合 1.1.添加Redis依赖 在Maven中添加Redis的依赖 redis.version2.9.0/redis.… 艳艳耶✌️个人主页 个人专栏 《Spring与Mybatis集成整合》《Vue.js使用》 ⛺️ 越努力 越幸运。 1.Redis与SSM的整合 1.1.添加Redis依赖 在Maven中添加Redis的依赖 redis.version2.9.0/redis.version redis.spring.version1.7.1.RELEASE/redis.spring.versiondependencygroupIdredis.clients/groupIdartifactIdjedis/artifactIdversion${redis.version}/version /dependency 1.2.spring-redis.xml的相关配置 1.2.1注册一个redis.properties redis.hostNamelocalhost redis.port6379 redis.password123456 redis.timeout10000 redis.maxIdle300 redis.maxTotal1000 redis.maxWaitMillis1000 redis.minEvictableIdleTimeMillis300000 redis.numTestsPerEvictionRun1024 redis.timeBetweenEvictionRunsMillis30000 redis.testOnBorrowtrue redis.testWhileIdletrue redis.expiration3600 但是当spring-context.xml中需要注册多个properties文件那么我们就不能够直接在spring-*.xml中添加注册因为这样子的话只能够读取一个配置文件另一个配置文件会被覆盖掉我们可以建一个文件用来专门引入外部文件 applicationContext ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/context xmlns:txhttp://www.springframework.org/schema/txxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd!--1. 引入外部多文件方式 --bean idpropertyConfigurerclassorg.springframework.beans.factory.config.PropertyPlaceholderConfigurerproperty namesystemPropertiesModeName valueSYSTEM_PROPERTIES_MODE_OVERRIDE /property nameignoreResourceNotFound valuetrue /property namelocationslistvalueclasspath:jdbc.properties/valuevalueclasspath:redis.properties/value/list/property/bean!-- 随着后续学习框架会越学越多不能将所有的框架配置放到同一个配制间否者不便于管理 --import resourceapplicationContext-mybatis.xml/importimport resourcespring-redis.xml/importimport resourceapplicationContext-shiro.xml/import /beans 那么pom.xml中也需要进行修改我们现在需要读取到所有的properties文件所以需要是*.properties文件而不能够指定是某一个配置文件 !--解决mybatis-generator-maven-plugin运行时没有将jdbc.properites文件放入target文件夹的问题--resourcedirectorysrc/main/resources/directoryincludesinclude*.properties/includeinclude*.xml/include/includes/resource 1.2.2配置数据源【连接池】 !-- 2. redis连接池配置--bean idpoolConfig classredis.clients.jedis.JedisPoolConfig!--最大空闲数--property namemaxIdle value${redis.maxIdle}/!--连接池的最大数据库连接数 --property namemaxTotal value${redis.maxTotal}/!--最大建立连接等待时间--property namemaxWaitMillis value${redis.maxWaitMillis}/!--逐出连接的最小空闲时间 默认1800000毫秒(30分钟)--property nameminEvictableIdleTimeMillis value${redis.minEvictableIdleTimeMillis}/!--每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3--property namenumTestsPerEvictionRun value${redis.numTestsPerEvictionRun}/!--逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1--property nametimeBetweenEvictionRunsMillis value${redis.timeBetweenEvictionRunsMillis}/!--是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个--property nametestOnBorrow value${redis.testOnBorrow}/!--在空闲时检查有效性, 默认false --property nametestWhileIdle value${redis.testWhileIdle}//bean 1.2.3连接工厂 !-- 3. redis连接工厂 --bean idconnectionFactory classorg.springframework.data.redis.connection.jedis.JedisConnectionFactorydestroy-methoddestroyproperty namepoolConfig refpoolConfig/!--IP地址 --property namehostName value${redis.hostName}/!--端口号 --property nameport value${redis.port}/!--如果Redis设置有密码 --property namepassword value${redis.password}/!--客户端超时时间单位是毫秒 --property nametimeout value${redis.timeout}//bean 1.2.4配置序列化器 !-- 4. redis操作模板,使用该对象可以操作redishibernate课程中hibernatetemplete相当于session专门操作数据库。--bean idredisTemplate classorg.springframework.data.redis.core.RedisTemplateproperty nameconnectionFactory refconnectionFactory/!--如果不配置Serializer那么存储的时候缺省使用String如果用User类型存储那么会提示错误User cant cast to String --property namekeySerializerbean classorg.springframework.data.redis.serializer.StringRedisSerializer//propertyproperty namevalueSerializerbean classorg.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer//propertyproperty namehashKeySerializerbean classorg.springframework.data.redis.serializer.StringRedisSerializer//propertyproperty namehashValueSerializerbean classorg.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer//property!--开启事务 --property nameenableTransactionSupport valuetrue//bean 1.2.5配置缓存管理器 !-- 5.配置缓存管理器 --bean idredisCacheManager classorg.springframework.data.redis.cache.RedisCacheManagerconstructor-arg nameredisOperations refredisTemplate/!--redis缓存数据过期时间单位秒--property namedefaultExpiration value${redis.expiration}/!--是否使用缓存前缀与cachePrefix相关--property nameusePrefix valuetrue/!--配置缓存前缀名称--property namecachePrefixbean classorg.springframework.data.redis.cache.DefaultRedisCachePrefixconstructor-arg index0 value-cache-//bean/property/bean 1.2.6配置redis的key生成策略 !--6.配置缓存生成键名的生成规则--bean idcacheKeyGenerator classcom.zking.ssm.redis.CacheKeyGenerator/bean 2.Redis的注解式开发 首先需要一个缓冲策略类用于储存信息 package com.sy.ssm.redis;import lombok.extern.slf4j.Slf4j; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.util.ClassUtils;import java.lang.reflect.Array; import java.lang.reflect.Method;Slf4j public class CacheKeyGenerator implements KeyGenerator {// custom cache keypublic static final int NO_PARAM_KEY 0;public static final int NULL_PARAM_KEY 53;Overridepublic Object generate(Object target, Method method, Object... params) {StringBuilder key new StringBuilder();key.append(target.getClass().getSimpleName()).append(.).append(method.getName()).append(:);if (params.length 0) {key.append(NO_PARAM_KEY);} else {int count 0;for (Object param : params) {if (0 ! count) {//参数之间用,进行分隔key.append(,);}if (param null) {key.append(NULL_PARAM_KEY);} else if (ClassUtils.isPrimitiveArray(param.getClass())) {int length Array.getLength(param);for (int i 0; i length; i) {key.append(Array.get(param, i));key.append(,);}} else if (ClassUtils.isPrimitiveOrWrapper(param.getClass()) || param instanceof String) {key.append(param);} else {//Java一定要重写hashCode和eqaulskey.append(param.hashCode());}count;}}String finalKey key.toString(); // IEDA要安装lombok插件log.debug(using cache key{}, finalKey);return finalKey;} } 2.1 Cacheable 注解 2.1.1、定义查询接口使用Cacheable注解 Spring会在其被调用后将其返回值缓存起来以保证下次利用同样的参数来执行该方法时可以直接从缓存中获取结果而不需要再次执行该方法。Spring在缓存方法的返回值时是以键值对进行缓存的值就是方法的返回结果。 package com.sy.ssm.biz;import com.sy.ssm.model.Clazz; import com.sy.ssm.util.PageBean;import org.springframework.cache.annotation.Cacheable;import java.util.List; import java.util.Map;public interface ClazzBiz {Cacheable(clz)Clazz selectByPrimaryKey(Integer cid);} 2.1.2.编写测试类 运行效果运行两次 2.2 自定义策略 Cacheable可以指定三个属性value、key和condition。  我可定义key值来修改我们保存到redis缓冲的key值并且可通过condition来制定什么时候需要缓冲进一步优化性能。 自定义策略如果查询的cid大于6才进行缓冲  package com.sy.ssm.biz;import com.sy.ssm.model.Clazz; import com.sy.ssm.util.PageBean;import org.springframework.cache.annotation.Cacheable;import java.util.List; import java.util.Map;public interface ClazzBiz {Cacheable(value clz,key cid:#cid,condition #cid 6)Clazz selectByPrimaryKey(Integer cid);} 2.3 CachePut 注解 它的使用与Cacheable的使用一致它们的区别 Cacheable会在redis中存储数据同时也会读取数据CachePut只会在redis储存数据不会进行读取操作 ppackage com.sy.ssm.biz;import com.sy.ssm.model.Clazz; import com.sy.ssm.util.PageBean;import org.springframework.cache.annotation.Cacheable;import java.util.List; import java.util.Map;public interface ClazzBiz {CachePut(value clz,key cid:#cid,condition #cid 6)Clazz selectByPrimaryKey(Integer cid);} 测试代码 3.Redis的击穿、穿透、雪崩  3.1.击穿 击穿指的是一个非常热门的数据在缓存中不存在导致所有的请求都直接到达数据库从而造成数据库负载过高甚至可能引起系统崩溃。这种情况常常发生在缓存中设置了过期时间的数据在数据失效的瞬间有大量请求同时涌入导致缓存无法命中并且每个请求都需要去访问数据库。 解决方案 使用互斥锁机制当一个请求发现缓存中不存在时可以使用互斥锁机制来确保只有一个线程去查询数据库其他线程等待查询结果。 提前异步加载在缓存过期之前提前异步加载数据到缓存避免缓存过期时大量请求同时到达数据库 3.2.穿透 穿透指的是请求的数据在缓存和数据库中都不存在这种情况通常是由于恶意请求或者非法请求导致的。这些请求绕过了缓存层直接访问数据库造成了数据库的压力增加资源浪费。 解决方案 参数校验在请求到达缓存之前可以进行参数校验过滤掉无效的请求。布隆过滤器Bloom Filter使用布隆过滤器可以判断一个请求对应的数据是否存在于数据库中如果不存在则可以直接拦截请求避免访问数据库 3.3.雪崩 雪崩指的是缓存中大量的数据同时失效导致所有请求都直接访问数据库从而造成数据库负载激增甚至导致系统崩溃。这种情况可能发生在缓存中的数据设置了相同的过期时间当过期时间到达时所有数据同时失效。 解决方案 设置不同的过期时间为不同的缓存数据设置稍有差异的过期时间避免所有数据同时失效。 使用热点数据预加载通过预先加载一些热门数据到缓存中来降低缓存同时失效的风险。 分布式锁机制在缓存数据失效时使用分布式锁机制确保只有一个线程去重新加载缓存其他线程等待缓存重新加载完成后再读取 解决方案         其实上述的这三种问题都有自己对应的解决方法但是他们也有一个共同的方法可以解决--限流 在Redis中限流是一种控制系统访问频率的机制用于限制对某个资源或服务的并发访问数量以防止系统过载或被恶意请求攻击。 限流的目的是通过限制请求的速率保护系统的稳定性和可用性。它可以帮助平衡系统的负载防止过多的请求同时涌入导致系统不堪重负。 今日分享就结束呐
http://www.w-s-a.com/news/340004/

相关文章:

  • 界面设计做的好的网站旅游商城网站模板
  • 大型电子商务网站 服务器硬件 cpu 内存 硬盘 2014美食网站开发意义
  • 建立网站的目的和意义网站建设寻求
  • 邢台手机网站建设设计师培训心得
  • 营销网站怎么做丽水微信网站建设哪家好
  • 南昌定制网站开发多少钱东阿县城市建设局网站
  • 浙江网站建设公司南昌seo招聘
  • 工业软件有哪些专业seo站长工具全面查询网站
  • 山东兴华建设集团有限公司网站和京东一样做电子产品的网站
  • 网站建设谢辞关于h5的网站模板
  • 网站改版提交WordPress360收录
  • 省级网站 开发建设 资质在国外怎么做网站
  • 中商华兴建设有限公司网站我的世界查找建筑网站
  • 广东网站设计公司百度推广免费送网站
  • 高密做网站哪家好网站建设预算
  • 免费wordpress网站模板重庆如何做聚政网站
  • 人才网站app建设建议系统开发生命周期法的优点表现
  • 门户网站想要微信登录怎么做湖南网站seo推广
  • 襄阳 网站建设管理系统网站
  • 重庆工程建设招标投标交易信息网广州外贸seo优化
  • 一个一起做网站东莞设计兼职网站建设
  • 杭州网站程序开发公司在哪个公司建设网站好
  • 网店的网站设计方案济南手机建站价格
  • 网站做了301重定向域名会自动跳转吗唐山地方志网站建设
  • 学校网站建设说明书海南省建设执业资格注册管理中心网站
  • 东莞哪家网站建设好网站风格设定
  • 自驾游网站模板搭建wordpress步骤
  • wordpress视频网站上传视频提升学历是什么意思
  • 江西省城乡建设厅建设网站浙江建设
  • 网站联系我们页面临平做网站