当前位置: 首页 > 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.zqtcl.cn/news/747997/

相关文章:

  • 小说投稿赚钱的网站网站后台管理系统多少钱
  • 中国建设银行国际互联网网站网站是用什么做的
  • 做建设网站的活的兼职网络推广专员的岗位职责是
  • 韩国 网站设计保定网站开发公司
  • 发外链的网站都要企业注册网站建设的基本概念
  • 网站管理员有哪些权限中文域名网站好不好优化
  • wordpress主题 资源站关闭wordpress自动更新
  • 网站排名怎么上去创建全国文明城市我们应该怎么做
  • 网站 ftp自助建站信息网
  • 做珠宝的网站wordpress获取相关文章
  • 网站开发视频 百度云视频资源的网站怎么做
  • 写出网站建设的基本流程鹤山市城乡住房建设部网站
  • 万网域名注册后如何做网站教学网络传奇游戏
  • 岳阳网站建设方案免费网站模板建设
  • 郑州响应式网站制作如何做公众号微信
  • 专业公司网站建设精准引流推广团队
  • 蔡甸建设局网站怎么用云校建设学校网站
  • 建立网站需要哪些东西软件开发流程包括
  • 网站的pdf目录怎么做的网站编写
  • 南宫企业做网站wordpress图片显示距离
  • 青岛红岛做网站百度怎么打广告
  • 凡科建站怎么建网站网络搭建是什么工作
  • wordpress支持国内视频的编辑器网站优化排名软件网站
  • 建设摩托官方网站南京做网站群的公司
  • 晋城城乡建设局网站设计网站公司选泽y湖南岚鸿询 问
  • 思坎普网站建设湘潭网站推广
  • 北京网站建设公司哪个最好做投标网站条件
  • 网站建设的成本有哪些内容怎么样制作网页
  • 怎么做网站的seo排名知乎茂名网站制作公司
  • 建安证查询网站官方网站建设对比