【Redis7】Spring Boot集成Redis(重点:集成RedisTemplate)

news2024/9/22 13:31:42

【大家好,我是爱干饭的猿,本文重点介绍Redis7 Spring Boot集成Redis,包括Jedis、lettuce、集成RedisTemplate、集群时一台master宕机,java报错的情况分析。

后续会继续分享Redis7和其他重要知识点总结,如果喜欢这篇文章,点个赞👍,关注一下吧】

上一篇文章:《【Redis7】Redis7 集群(重点:哈希槽分区)》


目录

🍖1. redis 配置文件

🍖2.Jedis

2.1 介绍

2.2 操作使用

🍖3. lettuce 

3.1 介绍

3.2 Jedis和Lettuce的区别

3.3 操作使用

🍖4. 集成RedisTemplate - 推荐使用

4.1 连接单机

1. 操作使用

2. 测试

4.2 连接集群

1.正常启动

2. 测试

3. 一台master宕机,java报错


🍖1. redis 配置文件

  • redis.conf配置文件,改完后确保生效,记得重启,记得重启
    • 默认daemonize no 改为 daemonize yes
    • 默认protected-mode yes 改为 protected-mode no
    • 默认bind 127.0.0.1 改为 直接注释掉(默认bind 127.0.0.1只能本机访问)或改成本机IP地址,否则影响远程IP连接
    • 添加redis密码 改为 requirepass 你自己设置的密码

🍖2.Jedis

2.1 介绍

Jedis Client 是Redis 官网推荐的一个面向 Java 客户端,库文件实现了对各类API进行封装调用。

2.2 操作使用

  • 新建项目

  • pom.xm

		<!--jedis-->
		<dependency>
			<groupId>redis.clients</groupId>
			<artifactId>jedis</artifactId>
			<version>4.3.1</version>
		</dependency>
  • yml文件

server.port=7777

spring.application.name=redis7_study
  • 业务类
package com.haomin.redis7_study.jedis_lettuce;

import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.Jedis;
import java.util.*;

/**
 * @author haomin
 * @date 2023/04/22 11:32
 **/
@Slf4j
public class JedisDemo {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("**.***.***.***", 6379);
        jedis.auth("***");
        log.info("redis conn status:{}", "连接成功");
        log.info("redis ping retvalue:{}", jedis.ping());

        jedis.set("k1","v1");
        jedis.set("k2","v2");
        jedis.set("k3","v3");

        Set<String> keys = jedis.keys("*");
        for (String key : keys) {
            System.out.println(key);
        }

        // String
        jedis.mset("m1", "v1","m2","v2","m3","v3");
        System.out.println(jedis.mget("m1", "m2","m3"));

        // list
        jedis.lpush("myList","v1","v2","v3","v4","v5");
        System.out.println(jedis.lrange("myList", 0, -1));

        // set
        jedis.sadd("orders","111");
        jedis.sadd("orders","222");
        jedis.sadd("orders","333");
        Set<String> set1 = jedis.smembers("orders");
        for(Iterator iterator = set1.iterator(); iterator.hasNext();) {
            String string = (String) iterator.next();
            System.out.println(string);
        }
        jedis.srem("orders","222");
        System.out.println(jedis.smembers("orders").size());

        //hash
        jedis.hset("hash1","userName","lisi");
        System.out.println(jedis.hget("hash1","userName"));
        Map<String,String> map = new HashMap<String,String>();
        map.put("telphone","138xxxxxxxx");
        map.put("address","atguigu");
        map.put("email","zzyybs@126.com");//课后有问题请给我发邮件
        jedis.hmset("hash2",map);
        List<String> result = jedis.hmget("hash2", "telphone","email");
        for (String element : result) {
            System.out.println(element);
        }

        //zset
        jedis.zadd("zset01",60d,"v1");
        jedis.zadd("zset01",70d,"v2");
        jedis.zadd("zset01",80d,"v3");
        jedis.zadd("zset01",90d,"v4");

        List<String> zset01 = jedis.zrange("zset01", 0, -1);
        zset01.forEach(System.out::println);
    }
}

🍖3. lettuce 

3.1 介绍

Lettuce是一个Redis的Java驱动包,Lettuce翻译为生菜

3.2 Jedis和Lettuce的区别

        jedis和Lettuce都是Redis的客户端,它们都可以连接Redis服务器,但是在SpringBoot2.0之后默认都是使用的Lettuce这个客户端连接Redis服务器。因为当使用Jedis客户端连接Redis服务器的时候,每个线程都要拿自己创建的Jedis实例去连接Redis客户端,当有很多个线程的时候,不仅开销大需要反复的创建关闭一个Jedis连接,而且也是线程不安全的,一个线程通过Jedis实例更改Redis服务器中的数据之后会影响另一个线程。

        但是如果使用Lettuce这个客户端连接Redis服务器的时候,就不会出现上面的情况,Lettuce底层使用的是Netty,当有多个线程都需要连接Redis服务器的时候,可以保证只创建一个Lettuce连接,使所有的线程共享这一个Lettuce连接,这样可以减少创建关闭一个Lettuce连接时候的开销;而且这种方式也是线程安全的,不会出现一个线程通过Lettuce更改Redis服务器中的数据之后而影响另—个线程的情况。

3.3 操作使用

  • pom.xml
		<!--lettuce-->
		<dependency>
			<groupId>io.lettuce</groupId>
			<artifactId>lettuce-core</artifactId>
			<version>6.2.1.RELEASE</version>
		</dependency>
  • 业务类
package com.haomin.redis7_study.jedis_lettuce;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.SortArgs;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisCommands;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author haomin
 * @date 2023/04/22 16:39
 **/
@Slf4j
public class LettuceDemo {
    public static void main(String[] args) {
        // 1.使用构建器链式编程来builder我们RedisURI
        RedisURI uri = RedisURI.builder()
                .redis("**.***.***.***")
                .withPort(6379)
                .withAuthentication("default", "***")
                .build();

        // 2.创建连接客户端
        RedisClient client = RedisClient.create(uri);
        StatefulRedisConnection conn = client.connect();

        // 3.通过conn创建操f作的comnand
        RedisCommands<String, String> commands = conn.sync();

        //===================操作=======================

        // keys
        List<String> list = commands.keys("*");
        for (String s : list) {
            log.info("key:{}", s);
        }
        commands.set("k1","1111");
        String s1 = commands.get("k1");
        System.out.println("String s ==="+s1);

        //list
        commands.lpush("myList2", "v1","v2","v3");
        List<String> list2 = commands.lrange("myList2", 0, -1);
        for(String s : list2) {
            System.out.println("list ssss==="+s);
        }

        //set
        commands.sadd("mySet2", "v1","v2","v3");
        Set<String> set = commands.smembers("mySet2");
        for(String s : set) {
            System.out.println("set ssss==="+s);
        }

        //hash
        Map<String,String> map = new HashMap<>();
        map.put("k1","111");
        map.put("k2","222");
        map.put("k3","333");

        commands.hmset("myHash2", map);
        Map<String,String> retMap = commands.hgetall("myHash2");
        for(String k : retMap.keySet()) {
            System.out.println("hash  k="+k+" , v=="+retMap.get(k));
        }

        //zset
        commands.zadd("myZset2", 100.0,"s1",110.0,"s2",90.0,"s3");
        List<String> list3 = commands.zrange("myZset2",0,10);
        for(String s : list3) {
            System.out.println("zset ssss==="+s);
        }

        //sort
        SortArgs sortArgs = new SortArgs();
        sortArgs.alpha();
        sortArgs.desc();

        List<String> list4 = commands.sort("myList2",sortArgs);
        for(String s : list4) {
            System.out.println("sort ssss==="+s);
        }

        //===================操作=======================

        //4. 关闭
        conn.close();
        client.shutdown();
    }
}

🍖4. 集成RedisTemplate - 推荐使用

4.1 连接单机

1. 操作使用

  • pom.xml
		<!--SpringBoot与Redis整合依赖-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-pool2</artifactId>
		</dependency>
		<!--swagger2-->
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>2.9.2</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.9.2</version>
		</dependency>
  • yml
server.port=7777

spring.application.name=redis7_study

# ========================logging=====================
logging.level.root=info
logging.level.com.atguigu.redis7=info
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger- %msg%n 

logging.file.name=D:/mylogs2023/redis7_study.log
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger- %msg%n

# ========================swagger=====================
spring.swagger2.enabled=true
#在springboot2.6.X结合swagger2.9.X会提示documentationPluginsBootstrapper空指针异常,
#原因是在springboot2.6.X中将SpringMVC默认路径匹配策略从AntPathMatcher更改为PathPatternParser,
# 导致出错,解决办法是matching-strategy切换回之前ant_path_matcher
spring.mvc.pathmatch.matching-strategy=ant_path_matcher

# ========================redis单机=====================
spring.redis.database=0
# 修改为自己真实IP
spring.redis.host=192.168.111.185
spring.redis.port=6379
spring.redis.password=111111
spring.redis.lettuce.pool.max-active=8
spring.redis.lettuce.pool.max-wait=-1ms
spring.redis.lettuce.pool.max-idle=8
spring.redis.lettuce.pool.min-idle=0
  • 业务类

  • config.redisConfig
package com.haomin.redis7_study.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author haomin
 * @date 2023/04/22 17:28
 **/
@Configuration
public class RedisConfig {
    /**
     * redis序列化的工具配置类,下面这个请一定开启配置
     * 127.0.0.1:6379> keys *
     * 1) "ord:102"  序列化过
     * 2) "\xac\xed\x00\x05t\x00\aord:102"   野生,没有序列化过
     * this.redisTemplate.opsForValue(); //提供了操作string类型的所有方法
     * this.redisTemplate.opsForList(); // 提供了操作list类型的所有方法
     * this.redisTemplate.opsForSet(); //提供了操作set的所有方法
     * this.redisTemplate.opsForHash(); //提供了操作hash表的所有方法
     * this.redisTemplate.opsForZSet(); //提供了操作zset的所有方法
     *
     * @param lettuceConnectionFactory
     * @return
     */
    @Bean
    public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();

        redisTemplate.setConnectionFactory(lettuceConnectionFactory);
        //设置key序列化方式string
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        //设置value的序列化方式json,使用GenericJackson2JsonRedisSerializer替换默认序列化
        redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());

        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());

        redisTemplate.afterPropertiesSet();

        return redisTemplate;
    }
}
  • config.SwaggerConfig
package com.haomin.redis7_study.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author haomin
 * @date 2023/04/22 17:28
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Value("${spring.swagger2.enabled}")
    private Boolean enabled;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(enabled)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.haomin.redis7_study")) //你自己的package
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("springboot利用swagger2构建api接口文档 " + "\t" + DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now()))
                .description("springboot+redis整合")
                .version("1.0")
                .termsOfServiceUrl("https://haomin.blog.csdn.net/")
                .build();
    }
}
  • controller.OrderController
package com.haomin.redis7_study.controller;

import com.haomin.redis7_study.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author haomin
 * @date 2023/04/22 17:52
 **/
// 访问:http://localhost:7777/swagger-ui.html#/

@Api(tags = "订单接口")
@RestController
@Slf4j
public class OrderController
{
    @Resource
    private OrderService orderService;

    @ApiOperation("新增订单")
    @RequestMapping(value = "/order/add",method = RequestMethod.POST)
    public void addOrder()
    {
        orderService.addOrder();
    }


    @ApiOperation("按orderId查订单信息")
    @RequestMapping(value = "/order/{id}", method = RequestMethod.GET)
    public String findUserById(@PathVariable Integer id)
    {
        return orderService.getOrderById(id);
    }
}
  • service.OrderService
package com.haomin.redis7_study.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author haomin
 * @date 2023/04/22 17:28
 **/

@Service
@Slf4j
public class OrderService {
    public static final String ORDER_KEY = "order:";

    @Resource
    private RedisTemplate redisTemplate;

    public void addOrder() {
        int keyId = ThreadLocalRandom.current().nextInt(1000) + 1;
        String orderNo = UUID.randomUUID().toString();
        redisTemplate.opsForValue().set(ORDER_KEY + keyId, "京东订单" + orderNo);
        log.info("=====>编号" + keyId + "的订单流水生成:{}", orderNo);
    }

    public String getOrderById(Integer id) {
        return (String) redisTemplate.opsForValue().get(ORDER_KEY + id);
    }
}

2. 测试

访问:访问:http://localhost:7777/swagger-ui.html#/

  • 如果使用RedisTemplate,推荐序列化用StringRedisSerializer,默认使用的是JdkSerializationRedisSerializer,存入Redis会出现乱码问题,查询非常不方便

4.2 连接集群

1.正常启动

  • 启动前面配的集群

  • 改写YML(注意IP和端口)

# ========================redis集群=====================
spring.redis.password=111111
# 获取失败 最大重定向次数
spring.redis.cluster.max-redirects=3
spring.redis.lettuce.pool.max-active=8
spring.redis.lettuce.pool.max-wait=-1ms
spring.redis.lettuce.pool.max-idle=8
spring.redis.lettuce.pool.min-idle=0
spring.redis.cluster.nodes=***.***.***.***:6381,***.***.***.***:6382 (主机:port)

2. 测试

访问:访问:http://localhost:7777/swagger-ui.html#/

3. 一台master宕机,java报错

  • 让master-6381宕机,shutdown

  • 查看集群信息 ,看slave是否上位 Cluster nodes

  • 我们客户端再次读写

  • 原因是因为SpringBoot客户端没有动态感知到RedisCluster的最新集群信息

  • 导致这个的原因是

    • Spring Boot 2,Redis默认的是 Lettuce
    • 当Redis集群节点发生变化后,Lettuce默认是不会刷新节点拓扑
  • 解决方法:

    1. 排除Lettuce采用jedis(不推荐)

      1.  

    2. 排除Lettuce采用jedis(不推荐)

    3. 刷新节点结群拓扑和动态感应(推荐)

      • 修改pom.xml

      • # ========================redis集群=====================
        spring.redis.password=111111
        # 获取失败 最大重定向次数
        spring.redis.cluster.max-redirects=3
        spring.redis.lettuce.pool.max-active=8
        spring.redis.lettuce.pool.max-wait=-1ms
        spring.redis.lettuce.pool.max-idle=8
        spring.redis.lettuce.pool.min-idle=0
        
        # ========================新增=====================
        #支持集群拓扑动态感应刷新,自适应拓扑刷新是否使用所有可用的更新,默认false关闭
        spring.redis.lettuce.cluster.refresh.adaptive=true
        #定时刷新
        spring.redis.lettuce.cluster.refresh.period=2000
        
        spring.redis.cluster.nodes=***.***.***.***:6381,***.***.***.***:6382 (主机:port)

reids初级篇分享到此,感谢大家观看!!!

如果你喜欢这篇文章,请点赞关注吧,或者如果你对文章有什么困惑,可以私信我。

🏓🏓🏓

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/465271.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

linux-02-软件安装-centos7配置jdk、tomcat、mysql、lrzsz、项目部署(Git、Maven)、shell脚本自动从git仓库获取项目更新★

文章目录 Linux-Day02课程内容1. 软件安装1.1 软件安装方式1.2 安装JDKshell脚本里写 cd命令不生效 1.3 安装Tomcat1.3.1 Tomcat安装好多方便的自定义命令:1.3.2 Tomcat进程查看1.3.3 防火墙操作1.3.4 停止Tomcat 1.4 安装MySQL1.4.1 MySQL安装1.4.2 MySQL启动1.4.3 MySQL登录1…

几何算法——7.Blending(倒角)的调研、设计及算法

几何算法——7.Blending&#xff08;倒角&#xff09;的调研、设计及算法 1 Parasolid的Blending1.1 关于Parasolid的BlendSurface1.2 Edge Blending1.2.1 Rolling-ball blends1.2.2 Variable rolling-ball blends1.2.3 Chamfers1.2.3.1 face offset chamfers1.2.3.2 apex-rang…

自学黑客/网络渗透,一般人我劝你还是算了

写在开篇 笔者本人 17 年就读于一所普通的本科学校&#xff0c;20 年 6 月在三年经验的时候顺利通过校招实习面试进入大厂&#xff0c;现就职于某大厂安全实验室。 我为啥说自学黑客&#xff0c;一般人我还是劝你算了吧。因为我就是那个不一般的人。 首先我谈下对黑客&…

AMBA总线协议AXI——学习笔记

文章目录 前言一、AXI&#xff08;Advanced eXtensible Interface&#xff09;1、定义2、信号2.1 全局信号2.2 写数据通路2.3 写地址通道2.4 写回复通道2.5 读数据通道2.6 读地址通道2.7 低功耗接口信号 3、AXI-Lite协议特点4、读写时序图4.1 读burst4.2 读重叠burst4.3 写burs…

Baklib母公司探码科技荣获甲子光年:2023中国AI数据平台创新企业

4月25日&#xff0c;由中国科技产业智库「甲子光年」主办、上海市信息服务业行业协会支持的「共赴山海2023甲子引力X智能新世代」峰会在上海召开。峰会上为了表彰在AI领域中取得卓越成就的公司&#xff0c;甲子光年在峰会现场颁布了星辰20&#xff1a;创新企业&#xff0c;表彰…

鹏程·盘古

鹏程盘古模型基于 1.1 TB 高质量中文训练数据&#xff0c;采用全场景人工智能计算框架 MindSpore 自动并行技术实现了五维并行训练策略&#xff0c;从而可将训练任务高效扩展到 4 096 个处理器上。 对比实验表明&#xff0c;在少样本或零样本情况下&#xff0c;鹏程盘古模型在…

Mysql高级知识-------索引

mysql索引的创建&#xff0c;新增&#xff0c;删除 查询索引&#xff1a; 语法&#xff1a; show index from 表 主要参数&#xff1a; 新建表中添加索引 ① 普通索引 create table t_dept( no int not null primary key, name varchar(20) null, sex varchar(2) null, inf…

讯飞星火大模型申请及测试:诚意满满

“ 大家好&#xff0c;我是可夫小子&#xff0c;关注AIGC、读书和自媒体。解锁更多ChatGPT、AI绘画玩法。加&#xff1a;keeepdance&#xff0c;备注&#xff1a;chatgpt&#xff0c;拉你进群。 最近国产大模型跟下饺子似&#xff0c;隔几天就发布一个。厂家发布得起劲&#xf…

ArduPilot之posHoldRTL实测

ArduPilot之posHold&RTL实测 1. 源由2. 模式配置3. 测试步骤4. 飞行实测5. 总结6. 参考资料7. 附录-关于QGC 暂不支持MAVLink2 signing Protocol问题7.1 问题描述7.2 硬件配置7.3 逻辑分析7.4 配置Signature7.5 总结&#xff08;QGC目前尚不支持MAVLink2 Signature&#xf…

算法——分布式——一致性哈希、一致性hash图解动画

分布式算法——一致性哈希、一致性Hash 概述传统Hash算法算法步骤生成Hash环定位服务器定位数据和映射服务器 服务器变更Hash环倾斜虚拟节点总结 概述 一致性哈希算法在1997年由麻省理工学院提出&#xff0c;是一种特殊的哈希算法&#xff0c;目的是解决分布式缓存的问题。在移…

使用bert4keras出现的问题(Process finished with exit code -1073741819 (0xC0000005))

1、环境 python 3.7.12 tensorflow 1.15 keras 2.3.1 bert4keras 0.9.7 protobuf 3.19.0 numpy 1.16.5 2、出现问题 numpy版本不兼容问题所以你就直接按照我的版本就可以了&#xff08;numpy 1.16.5&#xff09; Process finished with exit code -1073741819 (0xC0000005) …

关于储存器的笔记

存储器是许多存储单元的集合&#xff0c;按单元号顺序排列。每个单元由若干二进制位构成&#xff0c;以表示存储单元中存放的数值&#xff0c;通常由数组描述存储器。 存储器可分为主存储器(简称主存或内存)和辅助存储器(简称辅存或外存)两大类。和CPU直接交换信息的是主存。 …

HDCTF KEEP ON

Index KEEP ONChecksec & IDA漏洞分析完整EXP KEEP ON Checksec & IDA __int64 vuln() {char s[80]; // [rsp0h] [rbp-50h] BYREFmemset(s, 0, sizeof(s));puts("please show me your name: ");read(0, s, 0x48uLL);printf("hello,");printf(s);p…

2.5 习题分析

类型一、 通过收敛阶的定义分析迭代方法的收敛速度 例6 分析简单迭代法与牛顿迭代法的收敛速度 我的答案&#xff1a; 一、信息 1.分析简单迭代 2.分析牛顿迭代 3.二者的收敛速度 二、分析 条件1和条件2&#xff1a;告诉我此次分析的目标 条件3告诉我分析的方向即为收…

剑指 Offer 67. 把字符串转换成整数及复制带随机指针的链表

文章目录 一、剑指 Offer 67. 把字符串转换成整数二、Leetcode 138. 复制带随机指针的链表 一、剑指 Offer 67. 把字符串转换成整数 题目是这样的 字符串转换为整数&#xff0c;是连续的数字字符转换&#xff0c;如果数字字符不连续&#xff0c;只转换最前面连续的那部分 其实…

Axios的介绍与使用

Axios的介绍 get请求 Axios配置对象 创建实例发送请求 取消请求 Axios的介绍 目前前端最流行的 ajax 请求库 、react/vue 官方都推荐使用 axios 发 ajax 请求 特点&#xff1a; 基于 xhr promise 的异步 ajax 请求库浏览器端/node 端都可以使用支持请求&#xff0f;…

20.Java序列化

Java序列化 一、序列化和反序列化 序列化&#xff1a;指堆内存中的java对象数据&#xff0c;通过某种方式把对存储到磁盘文件中&#xff0c;或者传递给其他网络节点&#xff08;网络传输&#xff09;。这个过程称为序列化&#xff0c;通常是指将数据结构或对象转化成二进制的…

IPC行业信息汇总

IPC&#xff1a;“网络摄像机”&#xff0c;是IP Camera的简称。它是在前一代模拟摄像机的基础上&#xff0c;集成了编码模块后的摄像机。它和模拟摄像机的区别&#xff0c;就是在新增的“编码模块”上。 模拟摄像机&#xff0c;顾名思义&#xff0c;输出的是模拟视频信号。模拟…

大数据系列——Spark理论

概述 Apache Spark&#xff0c;全称伯克利数据分析栈&#xff0c;是一个开源的基于内存的通用分布式计算引擎&#xff0c;内部集成大量的通用算法&#xff0c;包括通用计算、机器学习、图计算等&#xff0c;用于处理大数据应用。 主要由下面几个核心构件组成&#xff0c;具体包…

C++、STL标准模板库和泛型编程 ——适配器、补充(侯捷)

C、STL标准模板库和泛型编程 ——适配器 &#xff08;侯捷&#xff09;--- 持续更新 适配器&#xff08;Adapters&#xff09;容器适配器&#xff08;Container Adapters&#xff09;仿函数适配器&#xff08;Functor Adapters&#xff09;bind2nd&#xff08;绑定第二实参&…