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

【业务功能篇92】微服务-springcloud-多线程-异步处理-异步编排-CompletableFutrue

三、CompletableFutrue

一个商品详情页

  • 展示SKU的基本信息 0.5s
  • 展示SKU的图片信息 0.6s
  • 展示SKU的销售信息 1s
  • spu的销售属性 1s
  • 展示规格参数 1.5s
  • spu详情信息 1s

1.ComplatableFuture介绍

  Future是Java 5添加的类,用来描述一个异步计算的结果。你可以使用 isDone方法检查计算是否完成,或者使用 get阻塞住调用线程,直到计算完成返回结果,你也可以使用 cancel方法停止任务的执行。

  虽然 Future以及相关使用方法提供了异步执行任务的能力,但是对于结果的获取却是很不方便,只能通过阻塞或者轮询的方式得到任务的结果。阻塞的方式显然和我们的异步编程的初衷相违背,轮询的方式又会耗费无谓的CPU资源,而且也不能及时地得到计算结果,为什么不能用观察者设计模式当计算结果完成及时通知监听者呢?

  很多语言,比如Node.js,采用回调的方式实现异步编程。Java的一些框架,比如Netty,自己扩展了Java的 Future接口,提供了 addListener等多个扩展方法;Google guava也提供了通用的扩展Future;Scala也提供了简单易用且功能强大的Future/Promise异步编程模式。

  作为正统的Java类库,是不是应该做点什么,加强一下自身库的功能呢?

  在Java 8中, 新增加了一个包含50个方法左右的类: CompletableFuture,提供了非常强大的Future的扩展功能,可以帮助我们简化异步编程的复杂性,提供了函数式编程的能力,可以通过回调的方式处理计算结果,并且提供了转换和组合CompletableFuture的方法。

  CompletableFuture类实现了Future接口,所以你还是可以像以前一样通过 get方法阻塞或者轮询的方式获得结果,但是这种方式不推荐使用。

  CompletableFuture和FutureTask同属于Future接口的实现类,都可以获取线程的执行结果。

image.png

2.创建异步对象

CompletableFuture 提供了四个静态方法来创建一个异步操作。

static CompletableFuture<Void> runAsync(Runnable runnable)
public static CompletableFuture<Void> runAsync(Runnable runnable, Executor executor)
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier)
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier, Executor executor)

方法分为两类:

  • runAsync 没有返回结果
  • supplyAsync 有返回结果
    private static ThreadPoolExecutor executor = new ThreadPoolExecutor(5,50,10, TimeUnit.SECONDS,new LinkedBlockingQueue<>(100), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());public static void main(String[] args) throws ExecutionException, InterruptedException {System.out.println("main -- 线程开始了...");// 获取CompletableFuture对象CompletableFuture<Void> voidCompletableFuture = CompletableFuture.runAsync(() -> {System.out.println("线程开始了...");int i = 100/50;System.out.println("线程结束了...");},executor);System.out.println("main -- 线程结束了...");System.out.println("------------");CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了...");int i = 100 / 50;System.out.println("线程结束了...");return i;}, executor);System.out.println("获取的线程的返回结果是:" + future.get() );}

3.whenXXX和handle方法

  当CompletableFuture的计算结果完成,或者抛出异常的时候,可以执行特定的Action。主要是下面的方法:

public CompletableFuture<T> whenComplete(BiConsumer<? super T,? super Throwable> action);
public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action);
public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor);public CompletableFuture<T> exceptionally(Function<Throwable,? extends T> fn);public <U> CompletableFuture<U> handle(BiFunction<? super T, Throwable, ? extends U> fn) ;
public <U> CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn) ;
public <U> CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) ;

相关方法的说明:

  • whenComplete 可以获取异步任务的返回值和抛出的异常信息,但是不能修改返回结果
  • execptionlly 当异步任务跑出了异常后会触发的方法,如果没有抛出异常该方法不会执行
  • handle 可以获取异步任务的返回值和抛出的异常信息,而且可以显示的修改返回的结果
/*** CompletableFuture的介绍*/
public class CompletableFutureDemo2 {private static ThreadPoolExecutor executor = new ThreadPoolExecutor(5,50,10, TimeUnit.SECONDS,new LinkedBlockingQueue<>(100), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了...");int i = 100 / 5;System.out.println("线程结束了...");return i;}, executor).handle((res,exec)->{System.out.println("res = " + res + ":exec="+exec);return res * 10;});// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + future.get() );}/*   public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了...");int i = 100 / 5;System.out.println("线程结束了...");return i;}, executor).whenCompleteAsync((res,exec)->{System.out.println("res = " + res);System.out.println("exec = " + exec);}).exceptionally((res)->{ // 在异步任务显示的抛出了异常后才会触发的方法System.out.println("res = " + res);return 10;});// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + future.get() );}*//*    public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了...");int i = 100 / 0;System.out.println("线程结束了...");return i;}, executor).whenCompleteAsync((res,exec)->{System.out.println("res = " + res);System.out.println("exec = " + exec);});// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + future.get() );}*/
}

4.线程串行方法

thenApply 方法:当一个线程依赖另一个线程时,获取上一个任务返回的结果,并返回当前任务的返回值。

thenAccept方法:消费处理结果。接收任务的处理结果,并消费处理,无返回结果。

thenRun方法:只要上面的任务执行完成,就开始执行thenRun,只是处理完任务后,执行 thenRun的后续操作

带有Async默认是异步执行的。这里所谓的异步指的是不在当前线程内执行。

public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn)
public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn)
public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)public CompletionStage<Void> thenAccept(Consumer<? super T> action);
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action);
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action,Executor executor);public CompletionStage<Void> thenRun(Runnable action);
public CompletionStage<Void> thenRunAsync(Runnable action);
public CompletionStage<Void> thenRunAsync(Runnable action,Executor executor);
/*** CompletableFuture的介绍*/
public class CompletableFutureDemo3 {private static ThreadPoolExecutor executor = new ThreadPoolExecutor(5,50,10, TimeUnit.SECONDS,new LinkedBlockingQueue<>(100), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());/*** 线程串行的方法* thenRun:在前一个线程执行完成后,开始执行,不会获取前一个线程的返回结果,也不会返回信息* thenAccept:在前一个线程执行完成后,开始执行,获取前一个线程的返回结果,不会返回信息* thenApply: 在前一个线程执行完成后。开始执行,获取前一个线程的返回结果,同时也会返回信息* @param args* @throws ExecutionException* @throws InterruptedException*/public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了..." + Thread.currentThread().getName());int i = 100 / 5;System.out.println("线程结束了..." + Thread.currentThread().getName());return i;}, executor).thenApply(res -> {System.out.println("res = " + res);return res * 100;});// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + future.get() );}/*public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Void> voidCompletableFuture = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了..." + Thread.currentThread().getName());int i = 100 / 5;System.out.println("线程结束了..." + Thread.currentThread().getName());return i;}, executor).thenAcceptAsync(res -> {System.out.println(res + ":" + Thread.currentThread().getName());}, executor);// 可以处理异步任务之后的操作//System.out.println("获取的线程的返回结果是:" + future.get() );}*//*public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Void> voidCompletableFuture = CompletableFuture.supplyAsync(() -> {System.out.println("线程开始了..."+Thread.currentThread().getName());int i = 100 / 5;System.out.println("线程结束了..."+Thread.currentThread().getName());return i;}, executor).thenRunAsync(() -> {System.out.println("线程开始了..."+Thread.currentThread().getName());int i = 100 / 5;System.out.println("线程结束了..."+Thread.currentThread().getName());}, executor);// 可以处理异步任务之后的操作//System.out.println("获取的线程的返回结果是:" + future.get() );}*/}

5.两个都完成

  上面介绍的相关方法都是串行的执行,接下来看看需要等待两个任务执行完成后才会触发的几个方法

  • thenCombine :可以获取前面两线程的返回结果,本身也有返回结果
  • thenAcceptBoth:可以获取前面两线程的返回结果,本身没有返回结果
  • runAfterBoth:不可以获取前面两线程的返回结果,本身也没有返回结果
/*** @param args* @throws ExecutionException* @throws InterruptedException*/public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Integer> future1 = CompletableFuture.supplyAsync(() -> {System.out.println("任务1 线程开始了..." + Thread.currentThread().getName());int i = 100 / 5;System.out.println("任务1 线程结束了..." + Thread.currentThread().getName());return i;}, executor);CompletableFuture<Integer> future2 = CompletableFuture.supplyAsync(() -> {System.out.println("任务2 线程开始了..." + Thread.currentThread().getName());int i = 100 /10;System.out.println("任务2 线程结束了..." + Thread.currentThread().getName());return i;}, executor);// runAfterBothAsync 不能获取前面两个线程的返回结果,本身也没有返回结果CompletableFuture<Void> voidCompletableFuture = future1.runAfterBothAsync(future2, () -> {System.out.println("任务3执行了");},executor);// thenAcceptBothAsync 可以获取前面两个线程的返回结果,本身没有返回结果CompletableFuture<Void> voidCompletableFuture1 = future1.thenAcceptBothAsync(future2, (f1, f2) -> {System.out.println("f1 = " + f1);System.out.println("f2 = " + f2);}, executor);// thenCombineAsync: 既可以获取前面两个线程的返回结果,同时也会返回结果给阻塞的线程CompletableFuture<String> stringCompletableFuture = future1.thenCombineAsync(future2, (f1, f2) -> {return f1 + ":" + f2;}, executor);// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + stringCompletableFuture.get() );}

6.两个任务完成一个

  在上面5个基础上我们来看看两个任务只要有一个完成就会触发任务3的情况

  • runAfterEither:不能获取完成的线程的返回结果,自身也没有返回结果
  • acceptEither:可以获取线程的返回结果,自身没有返回结果
  • applyToEither:既可以获取线程的返回结果,自身也有返回结果
/*** @param args* @throws ExecutionException* @throws InterruptedException*/public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Object> future1 = CompletableFuture.supplyAsync(() -> {System.out.println("任务1 线程开始了..." + Thread.currentThread().getName());int i = 100 / 5;System.out.println("任务1 线程结束了..." + Thread.currentThread().getName());return i;}, executor);CompletableFuture<Object> future2 = CompletableFuture.supplyAsync(() -> {System.out.println("任务2 线程开始了..." + Thread.currentThread().getName());int i = 100 /10;try {Thread.sleep(5000);} catch (InterruptedException e) {e.printStackTrace();}System.out.println("任务2 线程结束了..." + Thread.currentThread().getName());return i+"";}, executor);// runAfterEitherAsync 不能获取前面完成的线程的返回结果,自身也没有返回结果future1.runAfterEitherAsync(future2,()->{System.out.println("任务3执行了....");},executor);// acceptEitherAsync 可以获取前面完成的线程的返回结果  自身没有返回结果future1.acceptEitherAsync(future2,(res)->{System.out.println("res = " + res);},executor);// applyToEitherAsync 既可以获取完成任务的线程的返回结果  自身也有返回结果CompletableFuture<String> stringCompletableFuture = future1.applyToEitherAsync(future2, (res) -> {System.out.println("res = " + res);return res + "-->OK";}, executor);// 可以处理异步任务之后的操作System.out.println("获取的线程的返回结果是:" + stringCompletableFuture.get() );}

7.多任务组合

allOf:等待所有任务完成

anyOf:只要有一个任务完成

public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs);public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs);
/*** @param args* @throws ExecutionException* @throws InterruptedException*/public static void main(String[] args) throws ExecutionException, InterruptedException {CompletableFuture<Object> future1 = CompletableFuture.supplyAsync(() -> {System.out.println("任务1 线程开始了..." + Thread.currentThread().getName());int i = 100 / 5;System.out.println("任务1 线程结束了..." + Thread.currentThread().getName());return i;}, executor);CompletableFuture<Object> future2 = CompletableFuture.supplyAsync(() -> {System.out.println("任务2 线程开始了..." + Thread.currentThread().getName());int i = 100 /10;try {Thread.sleep(5000);} catch (InterruptedException e) {e.printStackTrace();}System.out.println("任务2 线程结束了..." + Thread.currentThread().getName());return i+"";}, executor);CompletableFuture<Object> future3 = CompletableFuture.supplyAsync(() -> {System.out.println("任务3 线程开始了..." + Thread.currentThread().getName());int i = 100 /10;System.out.println("任务3 线程结束了..." + Thread.currentThread().getName());return i+"";}, executor);CompletableFuture<Object> anyOf = CompletableFuture.anyOf(future1, future2, future3);anyOf.get();System.out.println("主任务执行完成..." + anyOf.get());CompletableFuture<Void> allOf = CompletableFuture.allOf(future1, future2, future3);allOf.get();// 阻塞在这个位置,等待所有的任务执行完成System.out.println("主任务执行完成..." + future1.get() + " :" + future2.get() + " :" + future3.get());}

相关文章:

【业务功能篇92】微服务-springcloud-多线程-异步处理-异步编排-CompletableFutrue

三、CompletableFutrue 一个商品详情页 展示SKU的基本信息 0.5s展示SKU的图片信息 0.6s展示SKU的销售信息 1sspu的销售属性 1s展示规格参数 1.5sspu详情信息 1s 1.ComplatableFuture介绍 Future是Java 5添加的类&#xff0c;用来描述一个异步计算的结果。你可以使用 isDone方…...

CAN FD的一致性测试 助力汽车电子智能化

后起之秀——CAN FD&#xff1a;随着各个行业的快速发展&#xff0c;消费者对汽车电子智能化的诉求越来越强烈&#xff0c;这使得整车厂将越来越多的电子控制系统加入到了汽车控制中&#xff0c;且在传统汽车、新能源汽车、ADAS和自动驾驶等汽车领域中也无不催生着更高的需求&a…...

微信短链跳转到小程序指定页面调试

首先说下背景&#xff1a;后端给了短链地址&#xff0c;但是无法跳转到指定页面。总是在小程序首页。指定的页面我们是h5页面。排查步骤如下&#xff1a; 1、通过快速URL Scheme 编译。上部普通编译 下拉找到此选项。 、 2、按照小程序的要求的URL Scheme输入。另外后端给的…...

机器学习——聚类算法一

机器学习——聚类算法一 文章目录 前言一、基于numpy实现聚类二、K-Means聚类2.1. 原理2.2. 代码实现2.3. 局限性 三、层次聚类3.1. 原理3.2. 代码实现 四、DBSCAN算法4.1. 原理4.2. 代码实现 五、区别与相同点1. 区别&#xff1a;2. 相同点&#xff1a; 总结 前言 在机器学习…...

【2023研电赛】安谋科技企业命题三等奖作品: 短临天气预报AI云图分析系统

本文为2023年第十八届中国研究生电子设计竞赛安谋科技企业命题三等奖分享&#xff0c;参加极术社区的【有奖活动】分享2023研电赛作品扩大影响力&#xff0c;更有丰富电子礼品等你来领&#xff01;&#xff0c;分享2023研电赛作品扩大影响力&#xff0c;更有丰富电子礼品等你来…...

The Sandbox 与韩国仁川市合作,打造身临其境的城市体验内容

简要概括 ● The Sandbox 与仁川市联手展示城市魅力&#xff0c;打造创新形象。 ● 本次合作包含多种多样的活动&#xff0c;如 NFT 捐赠活动和针对元宇宙创作者的培训计划。 我们非常高兴地宣布与仁川市合作&#xff0c;共同打造身临其境的城市体验。 双方合作的目的是在国…...

JVM之堆和方法区

目录 1.堆 1.1 堆的结构 1.1.1 新生代&#xff08;Young Generation&#xff09; 1.1.2 年老代&#xff08;Old Generation&#xff09; 1.1.3 永久代/元空间&#xff08;Permanent Generation/Metaspace&#xff09; 1.2 堆的内存溢出 1.3 堆内存诊断 1.3.1 jmap 1.3.2…...

Java 中的 IO 和 NIO

Java 中的 IO 和 NIO Java IO 介绍Java NIO&#xff08;New IO&#xff09;介绍windows 安装 ffmpeg完整示例参考文献 Java IO 介绍 Java IO&#xff08;Input/Output&#xff09;流是用于处理输入和输出数据的机制。它提供了一种标准化的方式来读取和写入数据&#xff0c;可以…...

Linux-crontab使用问题解决

添加定时进程 终端输入&#xff1a; crontab -e选择文本编辑方式&#xff0c;写入要运行的脚本&#xff0c;以及时间要求。 注意&#xff0c;如果有多个运行指令分两种情况&#xff1a; 1.多个运行指令之间没有耦合关系&#xff0c;分别独立&#xff0c;则可以直接分为两个…...

【设计模式】

文章目录 设计模式分类UML图类与类之间关系的表示方式 设计原则 设计模式分类 创建型模式 用于描述“怎样创建对象”&#xff0c;它的主要特点是“将对象的创建与使用分离”。单例、原型、工厂、抽象工厂、建造者等 5 种创建型模式。 结构型模式 用于描述如何将类或对象按某种…...

2023_Spark_实验四:SCALA基础

一、在IDEA中执行以下语句 或者用windows徽标R 输入cmd 进入命令提示符 输入scala直接进入编写界面 1、Scala的常用数据类型 注意&#xff1a;在Scala中&#xff0c;任何数据都是对象。例如&#xff1a; scala> 1 res0: Int 1scala> 1.toString res1: String 1scala…...

【深入解析spring cloud gateway】04 Global Filters

上一节学习了GatewayFilter。 回忆一下一个关键点&#xff1a; GateWayFilterFactory的本质就是&#xff1a;针对配置进行解析&#xff0c;为指定的路由&#xff0c;添加Filter&#xff0c;以便对请求报文进行处理。 一、原理分析 GlobalFilter又是啥&#xff1f;先看一下接口…...

c++搜索基础进阶

搜索算法基础 搜索算法是利用计算机的高性能来有目的的穷举一个问题的部分或所有的可能情况&#xff0c;从而求出问题的解的一种方法。搜索过程实际上是根据初始条件和扩展规则构造一棵解答树并寻找符合目标状态的节点的过程。 所有的搜索算法从其最终的算法实现上来看&#…...

管网水位监测的必要性

城市燃气、桥梁、供水、排水、热力、电力、电梯、通信、轨道交通、综合管廊、输油管线等&#xff0c;担负着城市的信息传递、能源输送、排涝减灾等重要任务&#xff0c;是维系城市正常运行、满足群众生产生活需要的重要基础设施&#xff0c;是城市的生命线。基础设施生命线就像…...

无涯教程-Android - 系统架构

Android操作系统是一堆软件组件&#xff0c;大致分为五个部分和四个主要层&#xff0c;如体系结构图中所示。 Linux内核 底层是Linux-Linux 3.6&#xff0c;带有大约115个补丁&#xff0c;这在设备硬件之间提供了一定程度的抽象&#xff0c;并且包含所有必需的硬件驱动程序&am…...

await接受成功的promise,失败的promise用try catch

在 JavaScript 中&#xff0c;await 关键字用于等待一个 Promise 对象的解决&#xff08;fulfillment&#xff09;。下面是一个示例&#xff1a; async function example() {try {const result await doSomethingAsync();console.log(result); // 如果 Promise 成功解决&…...

赞奇科技参与华为云828 B2B企业节,云工作站入选精选产品解决方案

8月27日&#xff0c;由华为云携手上万家伙伴共同发起的第二届 828 B2B 企业节拉开帷幕&#xff0c;围绕五大系列活动&#xff0c;为万千中小企业带来精细化商机对接。 聚焦行业数字化所需最优产品&#xff0c;举办超1000场供需对接会&#xff0c;遍及20多个省100多个城市&…...

Docker私有镜像仓库(Harbor)安装

Docker私有镜像仓库(Harbor)安装 1、什么是Harbor Harbor是类似与DockerHub 一样的镜像仓库。Harbor是由VMware公司开源的企业级的Docker Registry管理项目&#xff0c;它包括权限管理(RBAC)、LDAP、日志审核、管理界面、自我注册、镜像复制和中文支持等功能。Docker容器应用的…...

【深入解析spring cloud gateway】06 gateway源码简要分析

上一节做了一个很简单的示例&#xff0c;微服务通过注册到eureka上&#xff0c;然后网关通过服务发现访问到对应的微服务。本节将简单地对整个gateway请求转发过程做一个简单的分析。 一、核心流程 主要流程&#xff1a; Gateway Client向 Spring Cloud Gateway 发送请求请求…...

2023年行研行业研究报告

第一章 行业概述 1.1 行研行业 行业定义为同一类别的经济活动&#xff0c;这涉及生产相似产品、应用相同生产工艺或提供同类服务的集合&#xff0c;如食品饮料行业、服饰行业、机械制造行业、金融服务行业和移动互联网行业等。 为满足全球金融业的需求&#xff0c;1999年8月…...

linux上vscode中.cpp文件中引入头文件.hpp时报错:找不到头文件(启用错误钵形曲线)

当在.cpp文件中引入系统给定的头文件时&#xff1a;#include < iostream > 或者引入自定义的头文件 &#xff1a;#include <success.hpp> 报错&#xff1a;找不到相应的头文件&#xff0c;即在引入头文件的改行底下标出红波浪线 解决方法为&#xff1a; &#…...

Sphinx Docstring

入门 — Sphinx documentation pip install sphinx pip install sphinx-rtd-themesphinx-quickstartexport PYTHONPATH"-"make html cd build/htmlpython -m http.server 9121nohup python -m http.server 9121 &...

JVM的故事——虚拟机类加载机制

虚拟机类加载机制 文章目录 虚拟机类加载机制一、概述二、类加载的时机三、类加载的过程四、类加载器 一、概述 本章将要讲解class文件如何进入虚拟机以及虚拟机如何处理这些class文件。Java虚拟机把class文件加载到内存&#xff0c;并对数据进行校验、转换解析和初始化&#…...

Sentry 是一个开源的错误监控和日志聚合平台-- 通过docker-compose 安装Sentry

概述 Sentry 是一个开源的错误监控和日志聚合平台&#xff0c;用于帮助开发团队实时监控和调试应用程序中的错误和异常。它可以捕获应用程序中的错误和异常&#xff0c;并提供详细的错误报告&#xff0c;包括错误堆栈跟踪、环境信息、用户信息等。这些报告可以帮助开发团队快速…...

Redis 7 第六讲 主从模式(replica)架构篇

🌹🌹🌹 此篇开始进入架构篇范围(❤艸`❤) 理论 即主从复制,master以写为主,Slave以读为主。当master数据变化的时候,自动将新的数据异步同步到其它slave数据库。 使用场景 读写分离 容灾备份数据备份水平扩容主从架构 演示案例 注:masterauth、replicaof主…...

学习资源记录 =0=

学习路线&#xff1a; 无人机学习路线 无人机学习路线2 自主无人机&#xff1a; 浙大fastlab无人机 机器人理论&#xff1a; 华中科技大学机器人学 C课程 机器人仿真&#xff1a; 2023gazebo仿真开发四足机器人...

Python import包路径管理

import sys sys.path.insert(0, "../")详细链接...

OB Cloud助力泡泡玛特打造新一代分布式抽盒机系统

作为中国潮玩行业的领先者&#xff0c;泡泡玛特凭借 MOLLY、DIMOO、SKULLPANDA 等爆款 IP&#xff0c;以及线上线下全渠道营销收获了千万年轻人的喜爱&#xff0c;会员数达到 2600 多万。2022 年&#xff0c;泡泡玛特实现 46.2 亿元营收&#xff0c;其中线上渠道营收占比 41.8%…...

Linux socket网络编程实战(tcp)实现双方聊天

在上节已经系统介绍了大致的流程和相关的API&#xff0c;这节就开始写代码&#xff01; 回顾上节的流程&#xff1a; 创建一个NET文件夹 来存放网络编程相关的代码&#xff1a; tcp服务端代码初步实现--上 这部分先实现服务器的连接部分的代码并进行验证 server1.c&#xff…...

BuhoCleaner for mac:让你的Mac重获新生

你是否曾经因为电脑运行缓慢而感到困扰&#xff1f;是否曾经因为大量的垃圾文件和无效的临时文件而感到头疼&#xff1f;如果你有这样的烦恼&#xff0c;那么BuhoCleaner for mac就是你的救星&#xff01; BuhoCleaner for mac是一款专门为Mac用户设计的系统清理工具&#xff…...