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

网站界面设计原则网站设计方案图

网站界面设计原则,网站设计方案图,wordpress定时任务原理,可以随意建国际商城的网站吗今天小编给大家整理了springbootmybatis集成自定义缓存ehcache用法笔记#xff0c;希望对大家能有所办帮助#xff01;一、ehcache介绍EhCache 是一个纯Java的进程内缓存管理框架#xff0c;属于开源的Java分布式缓存框架#xff0c;主要用于通用缓存,Java EE和轻量级容器。…                今天小编给大家整理了springbootmybatis集成自定义缓存ehcache用法笔记希望对大家能有所办帮助一、ehcache介绍EhCache 是一个纯Java的进程内缓存管理框架属于开源的Java分布式缓存框架主要用于通用缓存,Java EE和轻量级容器。1、特点1. 简单、快速3. 提供多种缓存策略4. 缓存数据可分两级内存和磁盘5. 缓存数据会在服务器重启的过程中重新写入磁盘6. 可以通过RMI、可插入API等方式进行分布式缓存7. 具有缓存和缓存管理器的侦听接口8. 支持多缓存管理器实例以及一个实例的多个缓存区域9. 提供了Hibernate的缓存实现2、应用场景单应用或对缓存访问性能要求很高的应用适合简单共享适合缓存内容不大的场景比如MyBatis自定义缓存、系统配置信息、页面缓存。二、springbootmybatis集成ehcache步骤Spring Boot 的缓存机制高速缓存抽象不提供实际存储并且依赖于由org.springframework.cache.Cache和org.springframework.cache.CacheManager接口实现的抽象。 Spring Boot根据实现自动配置合适的CacheManager只要缓存支持通过EnableCaching注解启用即可。1、添加ehcache.xml配置文件?xml version1.0 encodingUTF-8? ehcache xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocationhttp://ehcache.org/ehcache.xsddiskStore pathjava.io.tmpdir /!-- 配置提供者 1、peerDiscovery提供者方式有两种方式自动发现(automatic)、手动配置(manual) 2、rmiUrls手动方式时提供者的地址多个的话用|隔开 --cacheManagerPeerProviderFactoryclassnet.sf.ehcache.distribution.RMICacheManagerPeerProviderFactorypropertiespeerDiscoverymanual,rmiUrls//127.0.0.1:40002/userCache /!-- cacheManagerPeerProviderFactoryclassnet.sf.ehcache.distribution.RMICacheManagerPeerProviderFactorypropertiespeerDiscoveryautomatic, multicastGroupAddress230.0.0.1, multicastGroupPort4446,timeToLive255/--!-- 配置监听器 1、hostName 主机地址 2、port 端口 3、socketTimeoutMillis socket子模块的超时时间默认是2000ms --cacheManagerPeerListenerFactoryclassnet.sf.ehcache.distribution.RMICacheManagerPeerListenerFactorypropertieshostName127.0.0.1, port40001, socketTimeoutMillis2000 /!-- cacheManagerPeerListenerFactoryclassnet.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory/ --defaultCache eternalfalse maxElementsInMemory1000overflowToDiskfalse diskPersistentfalse timeToIdleSeconds0timeToLiveSeconds600 memoryStoreEvictionPolicyLRU /cachenameuserCachemaxElementsInMemory1000eternalfalsetimeToIdleSeconds300timeToLiveSeconds300overflowToDiskfalsememoryStoreEvictionPolicyLRU!-- 配置缓存事件监听器 replicateAsynchronously 操作是否异步,默认值为true. replicatePuts 添加操作是否同步到集群内的其他缓存,默认为true.replicateUpdates 更新操作是否同步到集群内的其他缓存,默认为true. replicateUpdatesViaCopy 更新之后的对象是否复制到集群中的其他缓存(true);replicateRemovals 删除操作是否同步到集群内的其他缓存,默认为true. --cacheEventListenerFactoryclassnet.sf.ehcache.distribution.RMICacheReplicatorFactorypropertiesreplicateAsynchronouslytrue,replicatePutstrue,replicateUpdatestrue,replicateUpdatesViaCopytrue,replicateRemovalstrue /!-- 初始化缓存以及自动设置 --bootstrapCacheLoaderFactoryclassnet.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactorypropertiesbootstrapAsynchronouslytrue //cache/ehcache2、配置 application.properyies#cache 配置cache spring.cache.cache-namesuserCache spring.cache.jcache.configclasspath:ehcache.xml3、springboot启动类增加注解EnableCachingSpringBootApplication ComponentScan(basePackagescom.ehcache)//扫描组件 EnableCaching public class EhcacheTestApplication {public static void main(String[] args) {SpringApplication.run(EhcacheTestApplication.class, args);} }4、UserInfoService.java 文件增加缓存注解Service public class UserInfoService {Autowiredprivate UserDao userDao;CacheEvict(keyuser_#uid, valueuserCache)public void del(String uid) { userDao.del(uid);}CachePut(keyuser_#user.id, valueuserCache)public void update(User user) {userDao.update(user);}Cacheable(keyuser_#id,valueuserCache)public User getUserById(String id){ return userDao.findById(id); }CacheEvict(keyuser,valueuserCache)public String save(User user) { return userDao.save(user);} }5、增加测试控制器TestController.javapackage com.ehcache.controller;import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController;import com.ehcache.entity.User; import com.ehcache.factory.CacheManagerFactory; import com.ehcache.factory.UserFactory; import com.ehcache.service.UserService; import com.google.gson.Gson;import net.sf.ehcache.Element;RestController RequestMapping(/CacheTest) public class CacheTestController {Autowiredprivate UserService userService;Gson gson new Gson();CacheManagerFactory cmf CacheManagerFactory.getInstance();RequestMapping(value /test, method RequestMethod.GET)public String test(HttpServletRequest request){// 新增新用户String id userService.save(UserFactory.createUser());User user userService.getUserById(id);user.setUsername(小明);userService.update(user);// 查询该用户System.out.println(gson.toJson(user, User.class)); System.out.println();// 再查询该用户User user userService.getUserById(uid);System.out.println(gson.toJson(user, User.class));System.out.println();// 更新该用户userService.update(user);// 更新成功后再查询该用户 System.out.println(gson.toJson(userService.getUserById(id), User.class));System.out.println();// 删除该用户userService.del(id);System.out.println();// 删除后再查询该用户 System.out.println(gson.toJson(userService.getUserById(id), User.class));return id;} }IT技术分享社区个人博客网站https://programmerblog.xyz文章推荐程序员效率画流程图常用的工具程序员效率整理常用的在线笔记软件远程办公常用的远程协助软件你都知道吗51单片机程序下载、ISP及串口基础知识硬件断路器、接触器、继电器基础知识
http://www.huolong8.cn/news/288380/

相关文章:

  • 仙桃网站设计公司湖南seo推广系统
  • 网站建设方案书个人查公司注册信息怎么查
  • 湖北网站建设推荐磁力吧最佳搜索引擎
  • 网站 会员系统 织梦wordpress json 插件安装
  • 南庄营销网站建设肇庆企业做网站
  • 阜宁做网站价格微信小程序下单怎么弄商家
  • 免费制作单页的网站平面设计公司招聘
  • 网站开发如何无感更新东莞厚街劳务事件
  • 外贸建英文网站的重要性郑州网站建设系统介绍
  • 自考免费自学网站小程序登录功能
  • 机械类 网站源码wordpress 表 用户文章
  • 工具网站有哪些有做义工的相亲网站吗
  • 做网站会用到什么语言绍兴网站制作软件
  • 上海网站建设设计公司排名王欣网站建设与维护
  • 广州市官网网站建设深圳网站建设哪个平台好
  • 体检营销型网站美团服务商平台
  • 创建网站的免费软件国内wordpress建好站了打不开首页
  • 一级a做爰电影片免费网站注册网站平台
  • 东莞南海网站制作合肥网站建设模板系统
  • 潍坊网站建设服务商网站服务器租用年度价格
  • 高端定制网站开发原材料价格查询网站
  • 有专业做网站秦皇岛手机网站建设
  • 衡水网站开发四会网站建设
  • ppt模板 网站开发求有颜色的公众号
  • 高端网站设计v芯hyhyk1推好各大网站名称
  • 怎么网站建设公司flash+xml网站模板
  • asp.net 网站登陆设计网站说说模板.
  • 用wordpress建一个网站吗iis建多个网站
  • 自己做pc网站建设深圳调查公司
  • 公司网站设计开发公司多个wordpress用户