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

做百度网上搜索引擎推广最好网站trellis wordpress

做百度网上搜索引擎推广最好网站,trellis wordpress,iis网站目录权限设置,韩国网站模板下载地址转载自 Spring思维导图#xff0c;让Spring不再难懂#xff08;cache篇#xff09; 关于缓存 缓存是实际工作中非常常用的一种提高性能的方法。而在java中#xff0c;所谓缓存#xff0c;就是将程序或系统经常要调用的对象存在内存中#xff0c;再次调用时可以快速从内存…转载自 Spring思维导图让Spring不再难懂cache篇 关于缓存 缓存是实际工作中非常常用的一种提高性能的方法。而在java中所谓缓存就是将程序或系统经常要调用的对象存在内存中再次调用时可以快速从内存中获取对象不必再去创建新的重复的实例。这样做可以减少系统开销提高系统效率。 在增删改查中数据库查询占据了数据库操作的80%以上而非常频繁的磁盘I/O读取操作会导致数据库性能极度低下。而数据库的重要性就不言而喻了 数据库通常是企业应用系统最核心的部分数据库保存的数据量通常非常庞大数据库查询操作通常很频繁有时还很复杂 在系统架构的不同层级之间为了加快访问速度都可以存在缓存 spring cache特性与缺憾 现在市场上主流的缓存框架有ehcache、redis、memcached。spring cache可以通过简单的配置就可以搭配使用起来。其中使用注解方式是最简单的。 Cache注解 从以上的注解中可以看出虽然使用注解的确方便但是缺少灵活的缓存策略 缓存策略 TTLTime To Live 存活期即从缓存中创建时间点开始直到它到期的一个时间段不管在这个时间段内有没有访问都将过期 TTITime To Idle 空闲期即一个数据多久没被访问将从缓存中移除的时间 项目中可能有很多缓存的TTL不相同这时候就需要编码式使用编写缓存。 条件缓存 根据运行流程如下Cacheable将在执行方法之前( #result还拿不到返回值)判断condition如果返回true则查缓存  Cacheable(value  user, key  #id, condition  #id lt 10)   public User conditionFindById(final Long id)  如下CachePut将在执行完方法后#result就能拿到返回值了判断condition如果返回true则放入缓存 CachePut(value  user, key  #id, condition  #result.username ne zhang)   public User conditionSave(final User user)   如下CachePut将在执行完方法后#result就能拿到返回值了判断unless如果返回false则放入缓存即跟condition相反 CachePut(value  user, key  #user.id, unless  #result.username eq zhang)   public User conditionSave2(final User user)   如下CacheEvict beforeInvocationfalse表示在方法执行之后调用#result能拿到返回值了且判断condition如果返回true则移除缓存 CacheEvict(value  user, key  #user.id, beforeInvocation  false, condition  #result.username ne zhang)  public User conditionDelete(final User user)   小试牛刀综合运用 CachePut(value user, key #user.id)public User save(User user) {users.add(user);return user;}CachePut(value user, key #user.id)public User update(User user) {users.remove(user);users.add(user);return user;}CacheEvict(value user, key #user.id)public User delete(User user) {users.remove(user);return user;}CacheEvict(value user, allEntries true)public void deleteAll() {users.clear();}Cacheable(value user, key #id)public User findById(final Long id) {System.out.println(cache miss, invoke find by id, id: id);for (User user : users) {if (user.getId().equals(id)) {return user;}}return null;}配置ehcache与redis spring cache集成ehcachespring-ehcache.xml主要内容 dependencygroupIdnet.sf.ehcache/groupIdartifactIdehcache-core/artifactIdversion${ehcache.version}/version /dependency!-- Spring提供的基于的Ehcache实现的缓存管理器 --!-- 如果有多个ehcacheManager要在bean加上p:sharedtrue -- bean idehcacheManager classorg.springframework.cache.ehcache.EhCacheManagerFactoryBeanproperty nameconfigLocation valueclasspath:xml/ehcache.xml/ /beanbean idcacheManager classorg.springframework.cache.ehcache.EhCacheCacheManagerproperty namecacheManager refehcacheManager/property nametransactionAware valuetrue/ /bean!-- cache注解和spring-redis.xml中的只能使用一个 -- cache:annotation-driven cache-managercacheManager proxy-target-classtrue/spring cache集成redisspring-redis.xml主要内容 dependencygroupIdorg.springframework.data/groupIdartifactIdspring-data-redis/artifactIdversion1.8.1.RELEASE/version /dependency dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-pool2/artifactIdversion2.4.2/version /dependency dependencygroupIdredis.clients/groupIdartifactIdjedis/artifactIdversion2.9.0/version /dependency!-- 注意需要添加Spring Data Redis等jar包 -- descriptionredis配置/descriptionbean idjedisPoolConfig classredis.clients.jedis.JedisPoolConfigproperty namemaxIdle value${redis.pool.maxIdle}/property namemaxTotal value${redis.pool.maxActive}/property namemaxWaitMillis value${redis.pool.maxWait}/property nametestOnBorrow value${redis.pool.testOnBorrow}/property nametestOnReturn value${redis.pool.testOnReturn}/ /bean!-- JedisConnectionFactory -- bean idjedisConnectionFactory classorg.springframework.data.redis.connection.jedis.JedisConnectionFactoryproperty namehostName value${redis.master.ip}/property nameport value${redis.master.port}/property namepoolConfig refjedisPoolConfig/ /beanbean idredisTemplate classorg.springframework.data.redis.core.RedisTemplatep:connectionFactory-refjedisConnectionFactoryproperty namekeySerializerbean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer/bean/propertyproperty namevalueSerializerbean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer//propertyproperty namehashKeySerializerbean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer//propertyproperty namehashValueSerializerbean classorg.springframework.data.redis.serializer.JdkSerializationRedisSerializer//property /bean!--spring cache-- bean idcacheManager classorg.springframework.data.redis.cache.RedisCacheManagerc:redisOperations-refredisTemplate!-- 默认缓存10分钟 --property namedefaultExpiration value600/property nameusePrefix valuetrue/!-- cacheName 缓存超时配置半小时一小时一天 --property nameexpiresmap key-typejava.lang.String value-typejava.lang.Longentry keyhalfHour value1800/entry keyhour value3600/entry keyoneDay value86400/!-- shiro cache keys --entry keyauthorizationCache value1800/entry keyauthenticationCache value1800/entry keyactiveSessionCache value1800//map/property /bean !-- cache注解和spring-ehcache.xml中的只能使用一个 -- cache:annotation-driven cache-managercacheManager proxy-target-classtrue/ 项目中注解缓存只能配置一个所以可以通过以下引入哪个配置文件来决定使用哪个缓存。 import resourceclasspath:spring/spring-ehcache.xml/ !-- import resourceclasspath:spring/spring-redis.xml/--当然可以通过其他配置搭配使用两个缓存机制。比如ecache做一级缓存redis做二级缓存。 更加详细的使用与配置可以参考项目中spring-shiro-training中有关spring cache的配置。 https://git.oschina.net/wangzhixuan/spring-shiro-training.git
http://www.pierceye.com/news/747997/

相关文章:

  • 企业网站建设优化江门站官网
  • 网站开发的私活襄阳门户网站建设
  • 网站打不开第二天不收录啦如何制作个人网页缴费
  • 网页设计制作网站html代码怎么做网站的后台维护
  • 做体力活的网站如何推广个人网站
  • 网站建设指导ui培训完找工作没人要
  • 中国公司网站建设方案郑州网站制作汉狮
  • 网站制作com cn域名有什么区别黄志达设计公司官网
  • 网站整站优化方案wap注册
  • 建设主管部门官方网站html5旅游网站
  • 网站建设及维护流程深圳市手机网站建设品牌
  • 凡科做的网站被举报了会怎么样网络招商平台网站怎么做
  • 山东网站建设公司哪家权威嘉兴中小企业网站制作
  • 做网站的搜索引擎从代码角度分析网站怎么做
  • jsp小型网站开发南宁百度seo排名优化
  • 上海最专业的网站建设公司排名为什么上传网站模板网站上没有文字和图片
  • 网站建设灬金手指下拉十四自己做的网站与ie不兼容
  • 专业制作网站价格wordpress 安装语言包
  • 企业网站建设运营的灵魂是什么网站建设服务协议 百度
  • 注册了域名之后怎么做网站苏州市住房建设局网站
  • 免费做问卷的网站好新媒体培训
  • 网站建设 版权归属重庆建设监理协会网站
  • 游戏网站域名相城区网站建设
  • 很看好未来做生鲜的网站邢台做外贸网站
  • 网站首页点击中文英文链接 翻译成对应的语言 怎么做100种创意活动策划
  • 网站标题怎么设置小程序定制程序
  • discuz 网站搬家网站建设的工具
  • 有做国际网站生意吗做网站义乌
  • 网站开发技术可行性分析怎么写孝感建设公司网站
  • 灯塔网站建设有网站源码怎么做网站