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

麻涌公司网站建设公司学好seo

麻涌公司网站建设公司,学好seo,如何做网站后台,wordpress中footer函数我的上一个博客演示了Spring 3.1的Cacheable批注的应用#xff0c; Cacheable批注用于标记返回值将存储在缓存中的方法。 但是#xff0c; Cacheable只是Spring的Guy为缓存而设计的一对注释​​中的一个#xff0c;另一个是CacheEvict 。 像Cacheable一样#xff0c; Cache… 我的上一个博客演示了Spring 3.1的Cacheable批注的应用 Cacheable批注用于标记返回值将存储在缓存中的方法。 但是 Cacheable只是Spring的Guy为缓存而设计的一对注释​​中的一个另一个是CacheEvict 。 像Cacheable一样 CacheEvict具有value key和condition属性。 它们的工作方式与Cacheable支持的方式Cacheable 因此有关它们的更多信息请参见我以前的博客 Spring 3.1 Caching和Cacheable 。 CacheEvict支持两个附加属性 allEntries和beforeInvocation 。 如果我是一个赌博的人我会花钱买最受欢迎的allEntries 。 allEntries用于完全清除CacheEvict的强制value参数定义的高速缓存的内容。 下面的方法演示了如何应用allEntries CacheEvict(value employee, allEntries true)public void resetAllEntries() {// Intentionally blank} resetAllEntries()将CacheEvict的allEntries属性设置为“ true”并假定findEmployee(...)方法如下所示 Cacheable(value employee)public Person findEmployee(String firstName, String surname, int age) {return new Person(firstName, surname, age);} …然后在下面的代码resetAllEntries() 将清除“员工”缓存。 这意味着在JUnit测试中 employee1下面不会引用与employee2相同的对象 Testpublic void testCacheResetOfAllEntries() {Person employee1 instance.findEmployee(John, Smith, 22);instance.resetAllEntries();Person employee2 instance.findEmployee(John, Smith, 22);assertNotSame(employee1, employee2);} 第二个属性是beforeInvocation 。 这确定在调用方法之前或之后是否从缓存中清除数据项。 下面的代码非常荒谬。 但是它确实表明您可以同时将CacheEvict和Cacheable应用于方法。 CacheEvict(value employee, beforeInvocation true)Cacheable(value employee)public Person evictAndFindEmployee(String firstName, String surname, int age) {return new Person(firstName, surname, age);} 在上面的代码中 CacheEvict会在Cacheable搜索缓存之前使用匹配的键删除缓存中的所有条目。 由于Cacheable找不到任何条目因此它将调用我的代码将结果存储在缓存中。 对我的方法的后续调用将调用CacheEvict 它将删除任何适当的条目结果是在JUnit测试中变量下的employee1将永远不会引用与employee2相同的对象 Testpublic void testBeforeInvocation() {Person employee1 instance.evictAndFindEmployee(John, Smith, 22);Person employee2 instance.evictAndFindEmployee(John, Smith, 22);assertNotSame(employee1, employee2);} 就像我在上面说的那样由于我将Cacheable和CacheEvict都Cacheable同一方法 evictAndFindEmployee(...)似乎有点荒谬。 但是更重要的是它使代码不清楚并违反了单一责任原则。 因此我建议创建单独的可缓存和缓存退出方法。 例如如果您有一个缓存方法例如 Cacheable(value employee, key #surname)public Person findEmployeeBySurname(String firstName, String surname, int age) {return new Person(firstName, surname, age);} 然后假设您需要比简单的“清除所有”更好的缓存控制则可以轻松定义其对应项 CacheEvict(value employee, key #surname)public void resetOnSurname(String surname) {// Intentionally blank} 这是使用了已应用于同一规划环境地政司表达一个简单的空白标记方法Cacheable驱逐所有的Person 从其中关键的“姓”的说法相匹配的缓存实例。 Testpublic void testCacheResetOnSurname() {Person employee1 instance.findEmployeeBySurname(John, Smith, 22);instance.resetOnSurname(Smith);Person employee2 instance.findEmployeeBySurname(John, Smith, 22);assertNotSame(employee1, employee2);} 在上面的代码中对findEmployeeBySurname(...)的首次调用创建了一个Person对象Spring将其定义为“ Smith”的键存储在“员工”缓存中。 对resetOnSurname(...)的调用会清除“员工”缓存中所有姓为“ Smith”的条目最后第二次对findEmployeeBySurname(...)调用将创建一个新的Person对象Spring再次将其存储在“员工”缓存并带有“史密斯”键。 因此变量employee1和employee2没有引用相同的对象。 涵盖了Spring的缓存注释之后下一个难题是研究设置实用的缓存您如何启用Spring缓存以及应使用哪种缓存实现 稍后再说…… 祝您编程愉快别忘了分享 参考来自Captain Debug博客博客的JCG合作伙伴 Roger Hughes的Spring 3.1 Caching和CacheEvict 。 翻译自: https://www.javacodegeeks.com/2012/09/spring-31-caching-and-cacheevict.html
http://www.huolong8.cn/news/5091/

相关文章:

  • 恭城网站建设小甲虫抖音代运营
  • 电商网站建设 平台网站title字数
  • 南京seo整站优化技术ps怎样做网站详情页
  • 佳木斯建设网站做网站公司需要什么资质
  • 南宁模板建站wordpress 打赏 手机
  • 企业建设网站要注意的要素河北承德建设工程信息网站
  • 西安百度网站快速排名wordpress 点击排行
  • 关闭网站需要多久富顺住房和城乡建设厅网站
  • 手机建设银行网站o2o网站建设资讯
  • 东莞网站建设定制服务周到的微网站建设
  • 静态网站入侵教程wordpress shopy主题
  • 织梦者网站模板衡水做网站找谁
  • qingdao城乡住房建设厅网站贵阳做网站建设最好的是哪家
  • 郑州大型网站建设临沂网站推广排名
  • 深圳网站设计x沈阳关键词seo排名
  • 外贸类网站建设网络营销策划方案1500字
  • 怎么制作网站准考证在网上打印个人主页源码下载
  • 企业网站建设投标书做pc端网站价位
  • 违规网站开发 开发者如何规避风险网店运营流程步骤
  • 网站是生成静态好还是动态好平台建站建设
  • 企业所得税怎么算举例深圳短视频seo教程
  • 东城网站建设哪家好品牌营销策划ppt
  • 免费推广软件排行榜苏州推广关键词优化
  • 怎样做好网站用户体验网站建设工作量评估报价表
  • 深圳前50强网站建设公司做网站什么分类流量多
  • 网站建设项目招标公告北京专业网站设计推荐
  • 做网站怎么接业务泰安网站制作公司电话
  • 创建网站域名多少钱长沙网络推广哪家
  • 网站网站建设网站上面的彩票快3怎么做
  • 湛江高端网站开发google play