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

哪些网站用vue.js做的建设网站的相关费用

哪些网站用vue.js做的,建设网站的相关费用,建网站 多少钱钱,中企网络科技建站摘要#xff1a;web项目中做好基础架构(redis#xff0c;json)的序列化配置有重要意义 支持复杂数据结构#xff1a;Redis 支持多种不同的数据结构#xff0c;如字符串、哈希表、列表、集合和有序集合。在将这些数据结构存储到 Redis 中时#xff0c;需要将其序列化为字节…摘要web项目中做好基础架构(redisjson)的序列化配置有重要意义 支持复杂数据结构Redis 支持多种不同的数据结构如字符串、哈希表、列表、集合和有序集合。在将这些数据结构存储到 Redis 中时需要将其序列化为字节流。通过 JSON 序列化我们可以将复杂的数据结构如对象、数组等转换为字符串格式的 JSON 数据便于在 Redis 中存储和读取。减少网络传输量在分布式系统中Redis 通常用作缓存层。当应用程序需要从 Redis 中读取数据时需要通过网络传输数据。直接使用原始数据结构进行网络传输可能会消耗大量的带宽。通过 JSON 序列化可以将数据转换为紧凑的字符串格式从而减少网络传输量提高传输效率。跨平台兼容性JSON 是一种通用的数据交换格式具有广泛的跨平台兼容性。无论使用哪种编程语言或平台只要支持 JSON 格式就可以方便地进行数据交换和存储。这使得 Redis 中的数据可以轻松地与不同的应用程序或系统进行集成。数据可读性将数据序列化为 JSON 格式后可以方便地查看和调试数据。JSON 格式具有清晰的结构和可读性强的特点使得开发人员可以轻松地理解数据的含义和结构。对象持久化存储通过将对象序列化为 JSON 格式的字符串后可以将其存储到 Redis 中实现持久化存储。这样在应用程序重启或重新加载时可以轻松地恢复对象的状态。 Redis 序列化配置举例 Redis数据格式序列化配置类 /*** title Redis 基础配置类* desc 使用自己定义的 RedisTemplate Bean*/ AutoConfiguration(before RedissonAutoConfiguration.class) public class SingRedisAutoConfiguration {/*** 创建 RedisTemplate Bean使用 JSON 序列化方式*/Beanpublic RedisTemplateString, Object redisTemplate(RedisConnectionFactory factory) {// 创建 RedisTemplate 对象RedisTemplateString, Object template new RedisTemplate();// 设置 RedisConnection 工厂 实现多种 Java Redis 客户端接入template.setConnectionFactory(factory);// 使用 String 格式 KEYtemplate.setKeySerializer(RedisSerializer.string());// 使用 String 格式 序列化 哈希键template.setHashKeySerializer(RedisSerializer.string());// 使用 JSON 序列化方式(Jackson库)序列化 VALUE 。template.setValueSerializer(buildRedisSerializer());// 设置哈希值序列化器template.setHashValueSerializer(buildRedisSerializer());return template;}public static RedisSerializer? buildRedisSerializer() {RedisSerializerObject json RedisSerializer.json();// 序列化LocalDateTime 类型的日期字段ObjectMapper objectMapper (ObjectMapper) ReflectUtil.getFieldValue(json, mapper);objectMapper.registerModules(new JavaTimeModule());return json;}} 2. 全局 json 序列化配置类 AutoConfiguration Slf4j public class YudaoJacksonAutoConfiguration {BeanSuppressWarnings(InstantiationUtilClass)public JsonUtils jsonUtils(ListObjectMapper objectMappers) {// 创建 SimpleModule 对象SimpleModule simpleModule new SimpleModule();simpleModule// Long 自动序列化为字符串类型, 防止数值超过 2^53-1 在 JS 会出现精度丢失问题.addSerializer(Long.class, NumberSerializer.INSTANCE).addSerializer(Long.TYPE, NumberSerializer.INSTANCE).addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE).addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE).addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE).addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE)// LocalDateTime 序列化、反序列化规则使用 Long 时间戳.addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE).addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);// 注册到 objectMapperobjectMappers.forEach(objectMapper - objectMapper.registerModule(simpleModule));// 设置 objectMapper 到 JsonUtilsJsonUtils.init(CollUtil.getFirst(objectMappers));return new JsonUtils();}} 基于时间戳的 LocalDateTime 序列化器  /*** 基于时间戳的 LocalDateTime 序列化器**/ public class SingLocalDateTimeSerializer extends JsonSerializerLocalDateTime {public static final SingLocalDateTimeSerializer INSTANCE new SingLocalDateTimeSerializer();Overridepublic void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {// 将 LocalDateTime 对象 序列化为 Long 时间戳gen.writeNumber(value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());}} 基于时间戳的 LocalDateTime 反序列化器 /*** 基于时间戳的 LocalDateTime 反序列化器**/ public class SingLocalDateTimeDeserializer extends JsonDeserializerLocalDateTime {public static final SingLocalDateTimeDeserializer INSTANCE new SingLocalDateTimeDeserializer();Overridepublic LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {// 将 Long 时间戳 序列化为 LocalDateTime 对象return LocalDateTime.ofInstant(Instant.ofEpochMilli(p.getValueAsLong()), ZoneId.systemDefault());}}
http://www.dnsts.com.cn/news/131765.html

相关文章:

  • 做哪类英文网站赚钱货源网
  • 阳山做网站北京有哪些不错的互联网公司
  • 怎样给网站做推广竞价推广专员
  • 代理ip做网站流量山西省住房与城乡建设部网站
  • 制作商务网站wordpress上传中文图片不显示
  • 西安自助建站全景720效果图是什么软件
  • 网站后台怎么控制wordpress zip
  • 妇产医院网站源码wordpress媒体库太大
  • 扫二维码直接进网站怎么做如何自建网站 优帮云
  • dwcc2017怎么做网站山西微网站建设
  • 网站制作方案设计内蒙古建设工程社保中心网站
  • 如何自主建设企业网站手机seo关键词优化
  • 网站布局怎么写注册wordpress博客
  • 网站建设图片河南公司网站可以做天津备案吗
  • 刘素云网站脱孝怎样做网站欢迎屏怎么做
  • 音乐网站建设论文的目的和意义网站建设价格便宜
  • 龙岩网站设计招聘网禁止 外链 wordpress
  • 建网页还是网站wordpress 邮箱插件
  • 西安网站建设江苏今天刚刚的最新新闻
  • 网站建设合同范本简易版seo快速排名优化公司
  • 合肥政务新区建设局网站网站开发有哪些竞赛
  • 给网站网站做推广犯法对网站建设的描述
  • 深圳网站建设公司哪家可以建app重庆百度竞价开户
  • 如何建立一个学校网站中国农村建设网站首页
  • iis部署网站无法访问东莞网站建设设计公司哪家好
  • 网站全屏弹出窗口郑州seo顾问
  • 西安学校网站建设价格南昌百度网站快速排名
  • 企业建设网站怎么做账自学开发一个游戏app
  • 天津网站搜索引擎优化做动态效果的插件网站
  • 允许发外链的网站网上竞价平台