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

网站建设维护一年费用直播网站建设模板

网站建设维护一年费用,直播网站建设模板,学校网站建设方案模板下载,如何建网站教程springboot缓存技术-Ehcache-Redis-memcached 文章目录 springboot缓存技术-Ehcache-Redis-memcachedspring缓存使用方式手机验证码案例缓存供应商变更Ehcache变更缓存供应商Redis缓存供应商变更memcached下载安装memcachedSpringBoot整合memcached spring缓存使用方式 导缓存…springboot缓存技术-Ehcache-Redis-memcached 文章目录 springboot缓存技术-Ehcache-Redis-memcachedspring缓存使用方式手机验证码案例缓存供应商变更Ehcache变更缓存供应商Redis缓存供应商变更memcached下载安装memcachedSpringBoot整合memcached spring缓存使用方式 导缓存技术对应的starter dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-cache/artifactId/dependency/dependencies开启缓存 SpringBootApplication // 开启缓存功能 EnableCaching public class Springboot19CacheApplication {public static void main(String[] args) {SpringApplication.run(Springboot19CacheApplication.class, args);}} 设置当前操作结果数据进入缓存 OverrideCacheable(value cacheSpace,key #id)public Book getById(Integer id) {return bookDao.selectById(id);} 手机验证码案例 缓存供应商变更Ehcache 修改配置 cache:type: ehcacheehcache:config: classpath:ehcache.xml?xml version1.0 encodingUTF-8? ehcache xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocationhttp://ehcache.org/ehcache.xsdupdateCheckfalse!--diskStore为缓存路径ehcache分为内存和磁盘两级此属性定义磁盘的缓存位置。参数解释如下user.home – 用户主目录user.dir – 用户当前工作目录java.io.tmpdir – 默认临时文件路径--diskStore pathd:\ehcache/!--defaultCache默认缓存策略当ehcache找不到定义的缓存时则使用这个缓存策略。只能定义一个。--!--name:缓存名称。maxElementsInMemory:缓存最大数目maxElementsOnDisk硬盘最大缓存个数。eternal:对象是否永久有效一但设置了timeout将不起作用。overflowToDisk:是否保存到磁盘当系统当机时timeToIdleSeconds:设置对象在失效前的允许闲置时间单位秒。仅当eternalfalse对象不是永久有效时使用可选属性默认值是0也就是可闲置时间无穷大。timeToLiveSeconds:设置对象在失效前允许存活时间单位秒。最大时间介于创建时间和失效时间之间。仅当eternalfalse对象不是永久有效时使用默认是0.也就是对象存活时间无穷大。diskPersistent是否缓存虚拟机重启期数据 Whether the disk store persists between restarts of the Virtual Machine. The default value is false.diskSpoolBufferSizeMB这个参数设置DiskStore磁盘缓存的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。diskExpiryThreadIntervalSeconds磁盘失效线程运行时间间隔默认是120秒。memoryStoreEvictionPolicy当达到maxElementsInMemory限制时Ehcache将会根据指定的策略去清理内存。默认策略是LRU最近最少使用。你可以设置为FIFO先进先出或是LFU较少使用。clearOnFlush内存数量最大时是否清除。memoryStoreEvictionPolicy:可选策略有LRU最近最少使用默认策略、FIFO先进先出、LFU最少访问次数。FIFOfirst in first out这个是大家最熟的先进先出。LFU Less Frequently Used就是上面例子中使用的策略直白一点就是讲一直以来最少被使用的。如上面所讲缓存的元素有一个hit属性hit值最小的将会被清出缓存。LRULeast Recently Used最近最少使用的缓存的元素有一个时间戳当缓存容量满了而又需要腾出地方来缓存新的元素的时候那么现有缓存元素中时间戳离当前时间最远的元素将被清出缓存。--defaultCacheeternalfalsediskPersistentfalsemaxElementsInMemory1000overflowToDiskfalsetimeToIdleSeconds60timeToLiveSeconds60memoryStoreEvictionPolicyLRU/cachenamesmsCodeeternalfalsediskPersistentfalsemaxElementsInMemory1000overflowToDiskfalsetimeToIdleSeconds60timeToLiveSeconds60memoryStoreEvictionPolicyLRU//ehcache变更缓存供应商Redis 导坐标 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId/dependency改配置 cache:type: redisredis:use-key-prefix: truecache-null-values: falsekey-prefix: aatime-to-live: 10sredis:host: localhostport: 6379password: 123456 缓存供应商变更memcached 下载安装memcached SpringBoot整合memcached dependencygroupIdcom.googlecode.xmemcached/groupIdartifactIdxmemcached/artifactIdversion2.4.7/version/dependency因为springboot没有整合所以硬编码要自己配置 memcached:servers: localhost:11211poolSize: 10opTimeout: 3000 Component Data ConfigurationProperties(prefix memcached) public class XMemcachedProperties {private String servers;private int poolSize;private long opTimeout; } Configuration public class XMemcachedConfig {Autowiredprivate XMemcachedProperties memcachedProperties;Beanpublic MemcachedClient getMemcachedClient() throws IOException {MemcachedClientBuilder memcachedClientBuilder new XMemcachedClientBuilder(memcachedProperties.getServers());memcachedClientBuilder.setConnectionPoolSize(memcachedProperties.getPoolSize());memcachedClientBuilder.setOpTimeout(memcachedProperties.getOpTimeout());MemcachedClient memcachedClient memcachedClientBuilder.build();return memcachedClient;} } // 以下是springboot中使用xmemcachedAutowiredprivate MemcachedClient memcachedClient;Overridepublic String sendCodeToSMS(String tele) {String code codeUtils.generator(tele);try {memcachedClient.set(tele,0,code);} catch (Exception e) {throw new RuntimeException(e);}return code;}Overridepublic Boolean checkCode(SMSCode smsCode) {String code ;try {code memcachedClient.get(smsCode.getTele()).toString();} catch (Exception e) {throw new RuntimeException(e);}return smsCode.getCode().equals(code);}
http://www.zqtcl.cn/news/830006/

相关文章:

  • 城乡建设网站职业查询系统做网站设计的需要什么材料
  • ui做的好看的论坛网站加工制造网
  • 南庄网站开发厦门建设局网站城市建设
  • 常州网站建设效果重庆招聘网
  • 做视频网站需要多大的带宽公众号怎么开通直播功能
  • 信息化网站建设引言南宁 网站建设
  • 怎么做外贸网站的邮箱签名做网站页面怎么做
  • 做文库网站怎么赚钱吗百度网盘下载官网
  • 带后台的网站模板下载wordpress文章置顶插件
  • 云阳营销型网站建设北京梵客装饰公司地址电话
  • 北京有哪些网站建设公司好网站做配置文件的作用
  • 网站制作定制做网站顾客提现金额后台
  • 歙县建设银行网站人员优化是什么意思
  • 网站建设需解决问题wp商城
  • 简单房地产网站在哪老版建设银行网站
  • 外贸网站如何做推广苏州小程序需要写网站建设方案书
  • 哪些企业会考虑做网站婚庆策划公司简介
  • php网站开发个人个人学做网站
  • php网站开发最新需求网站建设实习心得
  • 深圳公司的网站设计网页制作视频教程下载
  • 动漫网站开发优势网站做电话线用
  • 河南移动商城网站建设广州营销型企业网站建设
  • 佛山做网站公司个人账号密码网站建设
  • 做零售网站智慧建筑信息平台
  • 山西住房建设厅官方网站建设部建造师网站
  • 加大门户网站安全制度建设wordpress切换数据库
  • 百度代理服务器株洲seo优化
  • 即刻搜索网站提交入口网站中的打赏怎么做的
  • 电子商务网站建设课后作业开发公司管理制度
  • mysql同一数据库放多少个网站表优化大师windows