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

政务网站建设规范intitlt 山西大同网站建设

政务网站建设规范,intitlt 山西大同网站建设,网络营销推广主要做什么?有哪些方法和技巧?,长尾关键词挖掘工具爱网站一、Spring Cache介绍 Spring Cache是一个框架#xff0c;实现了基于注解的缓存功能#xff0c;只需要简单地加一个注解#xff0c;就能实现缓存功能. Spring Cache提供了一层抽象#xff0c;底层可以切换不同的cache实现。具体就是通过CacheManager接口来统一不同的缓存…一、Spring Cache介绍 Spring Cache是一个框架实现了基于注解的缓存功能只需要简单地加一个注解就能实现缓存功能. Spring Cache提供了一层抽象底层可以切换不同的cache实现。具体就是通过CacheManager接口来统一不同的缓存技术。 CacheManager是Spring提供的各种缓存技术抽象接口。 针对不同的缓存技术需要实现不同的CacheManager: CacheManager描述EhCacheCacheManager使用EhCache作为缓存技术GuavaCacheManager使用Google的GuavaCache作为缓存技术RedisCacheManager使用Redis作为缓存技术 二、Spring Cache常用注解 Spring Cache提供了一些常用的注解用于控制缓存的行为。以下是几个常用的注解 注解说明EnableCaching开启缓存注解功能Cacheable在方法执行前spring先查看缓存中是否有数据如果有数据则直接返回缓存数据,若没有数据调用方法并将方法返回值放到缓存中CachePut表示将方法的返回值放到缓存中CacheEvict将一条或多条数据从缓存中删除Caching可以同时应用多个缓存相关的注解。 在spring boot项目中使用缓存技术只需在项目中导入相关缓存技术的依赖包 并在启动类上使用EnableCaching开启缓存支持即可。 例如使用Redis作为缓存技术只需要导入Spring data Redis的maven坐标即可 示例代码 Service public class UserService {Autowiredprivate UserRepository userRepository;Cacheable(value users, key #id)public User getUserById(Long id) {// 从数据库中获取用户信息return userRepository.findById(id);}CachePut(value users, key #user.id)public User updateUser(User user) {// 更新用户信息到数据库return userRepository.save(user);}CacheEvict(value users, key #id)public void deleteUserById(Long id) {// 从数据库中删除用户信息userRepository.deleteById(id);}Caching(evict {CacheEvict(value users, key #id1),CacheEvict(value users, key #id2)})public void deleteUsers(Long id1, Long id2) {// 批量删除用户信息userRepository.deleteByIdIn(Arrays.asList(id1, id2));} }三、Spring Cache使用方式 配置缓存管理器如 EhcacheManager bean idcacheManager classorg.springframework.cache.ehcache.EhCacheCacheManagerproperty namecacheManagerbean classorg.springframework.cache.ehcache.EhCacheManagerFactoryBeanproperty nameconfigLocation valueclasspath:ehcache.xml//bean/property /bean在需要缓存的方法上添加相应的注解如 Cacheable、CachePut、CacheEvict。 在需要使用缓存的类或方法上加上 EnableCaching 注解启用缓存功能。 Configuration EnableCaching public class CacheConfig {// 其他配置...Beanpublic CacheManager cacheManager() {return new EhCacheCacheManager(ehCacheManager());}Beanpublic net.sf.ehcache.CacheManager ehCacheManager() {// 配置 Ehcache 缓存管理器// ...} }通过以上的简单配置和注解使用我们就可以很方便地在 Spring 项目中引入缓存机制并提升系统的性能和响应速度。
http://www.yutouwan.com/news/366960/

相关文章:

  • 做网站 橙色怎么搭配官方网站下载穿越火线
  • 东莞网站建设方案企业kindeditor wordpress
  • 常用的网站推广方法有哪些织梦网站自助申请友链代码
  • 爱站网关键字查询网站如何实现微
  • 贵州网站建设服务平台网站认证打款怎么做分录
  • 长沙网站设计宁波自助建网站
  • 网站制作的基本流程专门做黄昏恋的网站
  • 做网站流程内容珠海网站搜索引擎优化
  • 制作投票网站移动互联网开发专业怎么样
  • 网站有哪些功能如何制作餐馆网站
  • html5 学习网站自适应 WordPress 主题
  • 做笑话网站ps软件网站有哪些功能
  • 代理公司代理注册流程seo排名点击器曝光行者seo
  • 学习网站 现状桂林网络推广外包
  • 通州区住房和城乡建设部网站dede单本小说网站源码
  • 浙江省建设注册管理中心网站首页wordpress移除工具栏
  • 建设银行东航龙卡登录东航网站一般家庭装修照片
  • 云网站7china网络公关公司
  • 济南seo排名优化推广seo推广薪资
  • 潜江市建设工程合同备案网站营销网站做推广公司
  • 自己做的影视会员网站违法么wordpress 4.6.1 漏洞
  • 物流公司网站 源码网站编辑做的准备
  • 北京网站建设咨询公司wordpress自动更新页面
  • 中企建网站阿里巴巴国际站特点
  • 品牌网站设计制作哪家好一站式服务的优点
  • 免费网站提供菏泽手机网站建设
  • 手机做推广比较好的网站有哪些房屋装修设计师培训
  • 做网站客户需要提供的资料719y你会回来感谢我的
  • 网站等比例缩放wordpress 上一篇 下一篇
  • 长春公司网站模板建站合肥网站制作价格