网站流量软件做网站学什么
- 作者: 五速梦信息网
- 时间: 2026年03月21日 07:31
当前位置: 首页 > news >正文
网站流量软件,做网站学什么,在哪个网站找地理题做,网站制作在线版redis整合redis的注解式开发及应用场景redis的击穿穿透雪崩 1.redis整合 mysql整合 pom配置#xff1b; String-fmybatis.xml – mybatis.cfg.xml: 包扫描#xff1b; 注册了一个jdbc.properties(url/password/username/…)#xff1b; 配置数据源#xff08;数据库连…redis整合redis的注解式开发及应用场景redis的击穿穿透雪崩 1.redis整合 mysql整合 pom配置 String-fmybatis.xml – mybatis.cfg.xml: 包扫描 注册了一个jdbc.properties(url/password/username/…) 配置数据源数据库连接池 配置sqlsession配置会话 配置事务… StringContext.xml中添加spring-mybatis.xml ?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. 注解式开发 –!– 注解驱动 –context:annotation-config/!– 用注解方式注入bean并指定查找范围com.javaxl.ssm及子子孙孙包–context:component-scan base-packagecom.zlj.ssm/context:property-placeholder locationclasspath:jdbc.properties/bean iddataSource classorg.apache.commons.dbcp2.BasicDataSourcedestroy-methodcloseproperty namedriverClassName value\({jdbc.driver}/property nameurl value\){jdbc.url}/property nameusername value\({jdbc.username}/property namepassword value\){jdbc.password}/!–初始连接数–property nameinitialSize value10/!–最大活动连接数–property namemaxTotal value100/!–最大空闲连接数–property namemaxIdle value50/!–最小空闲连接数–property nameminIdle value10/!–设置为-1时如果没有可用连接连接池会一直无限期等待直到获取到连接为止。–!–如果设置为N毫秒则连接池会等待N毫秒等待不到则抛出异常–property namemaxWaitMillis value-1//bean!–4. spring和MyBatis整合 –!–1) 创建sqlSessionFactory–bean idsqlSessionFactory classorg.mybatis.spring.SqlSessionFactoryBean!– 指定数据源 –property namedataSource refdataSource/!– 自动扫描XxxMapping.xml文件任意路径 –property namemapperLocations valueclasspath*:com/zlj/ssm//mapper/.xml/!– 指定别名 –property nametypeAliasesPackage valuecom/zlj/ssm//model/!–配置pagehelper插件–property namepluginsarraybean classcom.github.pagehelper.PageInterceptorproperty namepropertiesvaluehelperDialectmysql/value/property/bean/array/property/bean!–2) 自动扫描com/javaxl/ssm//mapper下的所有XxxMapper接口(其实就是DAO接口)并实现这些接口–!– 即可直接在程序中使用dao接口不用再获取sqlsession对象–bean classorg.mybatis.spring.mapper.MapperScannerConfigurer!–basePackage 属性是映射器接口文件的包路径。–!–你可以使用分号或逗号 作为分隔符设置多于一个的包路径–property namebasePackage valuecom/zlj/ssm/**/mapper/property namesqlSessionFactoryBeanName valuesqlSessionFactory//beanbean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource //beantx:annotation-driven transaction-managertransactionManager /aop:aspectj-autoproxy/ /beansredis整合 pom配置 Spring-redis.xml 注册了一个redis.properties.xml 配置注册源 连接工厂 配置序列化器 配置redis的key生成策略 StringContext.xml中添加spring-redis.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:cachehttp://www.springframework.org/schema/cachexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/cachehttp://www.springframework.org/schema/cache/spring-cache.xsd!– 1. 引入properties配置文件 –!–context:property-placeholder locationclasspath:redis.properties /–!– 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!– 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!– 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!– 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!–6.配置缓存生成键名的生成规则–bean idcacheKeyGenerator classcom.zlj.ssm.redis.CacheKeyGenerator/bean!–7.启用缓存注解功能–cache:annotation-driven cache-managerredisCacheManager key-generatorcacheKeyGenerator/ /beans 注解1当spring-content.xml中需要注解多个.propertise结尾的配置文件那么不能在spring-.xml添加注册在applicationContext-mybatis.xml里添加 ?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注解2resources的配置必须要涵盖读取.propertis结尾的文件 ?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注解3redistemplate的使用可以参照jdbcTemplate,amqptemplate,rabbitMQtemplate… 2.redis的注解式开发及应用场景 package com.zlj.ssm.biz;import com.zlj.ssm.model.Clazz; import com.zlj.ssm.util.PageBean; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut;import java.util.List; import java.util.Map;public interface ClazzBiz {CacheEvict(value xx,key cid:#cid,allEntries true)int deleteByPrimaryKey(Integer cid);int insert(Clazz record);int insertSelective(Clazz record);// xxcache-cid:1 // key的作用改变原有的key生成规则 // Cacheable(value xx,key cid:#cid,condition #cid 6)CachePut(value xx,key cid:#cid,condition #cid 6)Clazz selectByPrimaryKey(Integer cid);int updateByPrimaryKeySelective(Clazz record);int updateByPrimaryKey(Clazz record);ListClazz listPager(Clazz clazz, PageBean pageBean);ListMap listMapPager(Clazz clazz, PageBean pageBean); } cacheable会在redis中存储数据同时也会读取数据 cacheput只会在redis中写数据不会读数据 cacgeEict强行清除缓存问题redis与mybatis的性能同步问题 cacgeEict(value xx,key cid:#cid,allEntries true); 3.redis的击穿穿透雪崩 缓存击穿 redis中一个热点key刚好过期大量用户访问该热点key但是热点key刚好过期 缓存击穿解决方案 进行预先的热门词汇的设置进行key时长的调整 实时调整监控哪些数据是热门数据实时的调整key的过期时长 使用锁机制(只有一个线程可以进行热点数据的重构) 缓存穿透 大量请求根本不存在的key 缓存穿透解决方案 对空值进行缓存 设置白名单 使用布隆过滤器 网警 缓存雪崩 redis中大量key集体同一时间过期 缓存雪崩解决方案 进行预先的热门词汇的设置进行key时长的调整 实时调整监控哪些数据是热门数据实时的调整key的过期时长 使用锁机制
- 上一篇: 网站流量如何提高wordpress收集客户插件
- 下一篇: 网站流量通道百度图片识别在线使用
相关文章
-
网站流量如何提高wordpress收集客户插件
网站流量如何提高wordpress收集客户插件
- 技术栈
- 2026年03月21日
-
网站流量攻击拉扎斯网络科技上海有限公司
网站流量攻击拉扎斯网络科技上海有限公司
- 技术栈
- 2026年03月21日
-
网站流量分析系统建设网站的建设费用包括
网站流量分析系统建设网站的建设费用包括
- 技术栈
- 2026年03月21日
-
网站流量通道百度图片识别在线使用
网站流量通道百度图片识别在线使用
- 技术栈
- 2026年03月21日
-
网站流量统计表格网站的规划与创建
网站流量统计表格网站的规划与创建
- 技术栈
- 2026年03月21日
-
网站流量统计实现公司变更法人一般需要多少时间
网站流量统计实现公司变更法人一般需要多少时间
- 技术栈
- 2026年03月21日
