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

新乡网站开发wordpress网站如何

新乡网站开发,wordpress网站如何,wordpress文章调用代码,网站制作主题目录 缓存支持 缓存集成 redis缓存集成 缓存支持 Spring 框架只提供抽象#xff0c;不提供具体的缓存存储#xff0c;底层需要依赖第三方存储组件#xff0c;如果当前应用没有注册CacheManager 或者 CacheResolver 实例#xff0c;Spring Boot 会按以下缓存组件的顺序来…目录 缓存支持 缓存集成 redis缓存集成 缓存支持 Spring 框架只提供抽象不提供具体的缓存存储底层需要依赖第三方存储组件如果当前应用没有注册CacheManager 或者 CacheResolver 实例Spring Boot 会按以下缓存组件的顺序来检测: GenericJCache (SR-107)(EhCache 3, Hazelcast, Infinispan 等等)HazelcastlnfinispanCouchbaseredis ........ Spring Boot的自动配置类为CacheAutoConfiguration在 CacheAutoConfiguration 缓存自动配置类中引入了 CacheConfigurationImportSelector 配置选择器 AutoConfiguration(after { CouchbaseDataAutoConfiguration.class, HazelcastAutoConfiguration.class,HibernateJpaAutoConfiguration.class, RedisAutoConfiguration.class }) ConditionalOnClass(CacheManager.class) ConditionalOnBean(CacheAspectSupport.class) ConditionalOnMissingBean(value CacheManager.class, name cacheResolver) EnableConfigurationProperties(CacheProperties.class) Import({ CacheConfigurationImportSelector.class, CacheManagerEntityManagerFactoryDependsOnPostProcessor.class }) public class CacheAutoConfiguration {...static class CacheConfigurationImportSelector implements ImportSelector {Overridepublic String[] selectImports(AnnotationMetadata importingClassMetadata) {CacheType[] types CacheType.values();String[] imports new String[types.length];for (int i 0; i types.length; i) {imports[i] CacheConfigurations.getConfigurationClass(types[i]);}return imports;}} 该选择器通过 CacheConfiqurations 缓存配置类来选择对应缓存组件的配置类 final class CacheConfigurations {private static final MapCacheType, String MAPPINGS;static {MapCacheType, String mappings new EnumMap(CacheType.class);mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class.getName());mappings.put(CacheType.HAZELCAST, HazelcastCacheConfiguration.class.getName());mappings.put(CacheType.INFINISPAN, InfinispanCacheConfiguration.class.getName());mappings.put(CacheType.JCACHE, JCacheCacheConfiguration.class.getName());mappings.put(CacheType.COUCHBASE, CouchbaseCacheConfiguration.class.getName());mappings.put(CacheType.REDIS, RedisCacheConfiguration.class.getName());mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class.getName());mappings.put(CacheType.CACHE2K, Cache2kCacheConfiguration.class.getName());mappings.put(CacheType.SIMPLE, SimpleCacheConfiguration.class.getName());mappings.put(CacheType.NONE, NoOpCacheConfiguration.class.getName());MAPPINGS Collections.unmodifiableMap(mappings);}...代码...} 缓存集成 依赖配置 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-cache/artifactId /dependency 加入依赖后通过使用EnableCaching注解来启用缓存功能。通过参数type指定要使用的缓存组件以redis为示例 spring:cache: type: redis 禁用缓存 spring:cache: type: none 缓存类型type的值 GENERIC: 通用缓存类型HAZELCAST: Hazelcast 缓存类型INFINISPAN: Infinispan 缓存类型JCACHE: JCache 缓存类型COUCHBASE: Couchbase 缓存类型REDIS: Redis 缓存类型CAFFEINE: Caffeine 缓存类型CACHE2K: Cache2k 缓存类型SIMPLE: 简单缓存类型NONE: 无缓存类型 redis缓存集成 在Spring Boot 2.7中使用EnableCaching注解启用缓存功能时如果你想使用Redis作为缓存存储你需要在配置文件中指定Redis的相关配置。 application.properties或application.yml文件中添加以下配置 spring:cache:type: redis # 指定缓存使用redisredis:host: 127.0.0.1 # Redis服务器地址database: 1 # Redis数据库索引默认为0port: 6379 # Redis服务器连接端口password: # Redis服务器连接密码默认为空 依赖配置 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId /dependency 配置缓存管理器 Configuration EnableCaching public class RedisTemplateConfiguration {/*** 默认过期时长单位秒*/Getterprivate long expire 60 * 60 * 24; ​Beanpublic RedisTemplateString, Object redisTemplate(RedisConnectionFactory factory) {RedisTemplateString, Object redisTemplate new RedisTemplate();redisTemplate.setKeySerializer(RedisSerializer.string());redisTemplate.setHashKeySerializer(RedisSerializer.string());redisTemplate.setValueSerializer(RedisSerializer.java());redisTemplate.setHashValueSerializer(RedisSerializer.java());redisTemplate.setConnectionFactory(factory);return redisTemplate;} ​Beanpublic HashOperationsString, String, Object hashOperations(RedisTemplateString, Object redisTemplate) {return redisTemplate.opsForHash();} ​Beanpublic ValueOperationsString, String valueOperations(RedisTemplateString, String redisTemplate) {return redisTemplate.opsForValue();} ​Beanpublic ListOperationsString, Object listOperations(RedisTemplateString, Object redisTemplate) {return redisTemplate.opsForList();} ​Beanpublic SetOperationsString, Object setOperations(RedisTemplateString, Object redisTemplate) {return redisTemplate.opsForSet();} ​Beanpublic ZSetOperationsString, Object zSetOperations(RedisTemplateString, Object redisTemplate) {return redisTemplate.opsForZSet();} }
http://www.dnsts.com.cn/news/109549.html

相关文章:

  • 长沙做手机网站高校网站建设工作总结
  • 劳务外包seo案例分析
  • 做网站很难吗怎么仿做网站
  • 深圳网站建设制作设计企业网站搭建代理
  • 开个免费的网站多少钱卖二手手表的网站
  • 湖北省建设厅乡镇污水官方网站建设公司网站征集信息的通知
  • 网站备案 申请wordpress 链接新窗口
  • 新华路网站建设传媒网站设计
  • 阿里云做网站官网公司网站生成二维码
  • 首都在线官网网站网站的一般制作流程
  • remix做歌网站app手机网站开发
  • 百度竞网建设网站sem seo什么意思
  • 网站设计经典案例分析pageadmin仿站教程
  • 网站开发的架构辽宁营口建设工程信息网站
  • 微网站建设行业现状外国ps修图网站
  • 资源型网站建设 需要多大硬盘全国火车站等级最新排名
  • cms免费建站系统美工网站设计
  • 建设公司设计公司网站企业网站icp是什么
  • nike官方网站定制做旅游网站需要的背景
  • 太原市建设局网站mysql 上传wordpress
  • 网站做的好有什么用海南在线分类信息平台
  • 电商网站开发流程文档江苏百度推广代理商
  • 汕头网站建设stqhcx电子商务的概念
  • 17网站一起做网店类似的网站开发大概价格
  • 华为云做网站北京建筑网
  • 用手机怎么做网站网络编程技术栈
  • 东莞网站页设计制作wordpress 图标 png
  • 中国空间站建造历程卖手表的网站
  • 山东省水利建设市场信用信息平台网站丹灶做网站
  • 邯郸网站建设选哪家好如何建设好企业的网站维护