当前位置:首页>java>告别低效编程!一文教你玩转CompletableFuture高级特性:超时、重试与并行流

告别低效编程!一文教你玩转CompletableFuture高级特性:超时、重试与并行流

  • 2026-02-05 00:39:47
告别低效编程!一文教你玩转CompletableFuture高级特性:超时、重试与并行流

点击上方蓝字加入我们

往期推荐

探索CompletableFuture:它凭什么能取代Future,成为编程界的新星?

CompletableFuture进阶指南:打造强大的链式调用与任务组合

告别静默失败!揭秘CompletableFuture异步任务的完美解决方案

告别资源耗尽!一文教你玩转CompletableFuture线程池配置

引言
在前面的篇章中,我们掌握了 CompletableFuture 的核心 API、异常处理和线程池配置,能够应对大部分常规异步场景。但在生产环境中,还会遇到任务超时 、 失败重试 、 与并行流结合等更复杂的需求。
本篇将深入讲解 CompletableFuture 的高级特性,包括超时控制 、 失败重试机制 、 与 Stream 并行流的协同使用,以及 异步任务的编排模式 ,帮你打造更健壮、更灵活的异步编程方案。
超时控制:避免异步任务无限等待
在异步编程中, 超时控制是必不可少的 —— 如果一个异步任务因为网络故障或服务宕机一直阻塞,会导致资源泄漏和请求堆积。CompletableFuture 提供了 orTimeout() 和 completeOnTimeout() 两个方法,实现优雅的超时处理。
orTimeout ():超时抛出异常
orTimeout() 方法的核心作用是:当任务在指定时间内未完成时,抛出 TimeoutException 异常,可以结合异常处理 API 实现降级逻辑。
方法定义
public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit)
  • timeout:超时时间阈值
  • unit:时间单位
  • 超时后任务会被标记为异常状态,抛出 TimeoutException
实战示例:接口调用的超时控制
import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit;public class OrTimeoutDemo {    private static final ExecutorService executor = Executors.newFixedThreadPool(2);    // 模拟远程接口调用    private static CompletableFuture<StringcallRemoteApi(String url) {        return CompletableFuture.supplyAsync(() -> {            try {                // 模拟接口响应延迟                Thread.sleep(2000);            } catch (InterruptedException e) {                throw new RuntimeException(e);            }            return url + " 响应结果";        }, executor);    }    public static void main(String[] args) {        CompletableFuture<String> future = callRemoteApi("https://api.example.com")                // 设置超时时间为1秒                .orTimeout(1TimeUnit.SECONDS)                // 超时异常降级                .exceptionally(ex -> {                    System.out.println("接口调用超时:" + ex.getMessage());                    return "默认降级结果";                });        System.out.println("最终结果:" + future.join());        executor.shutdown();    }}
运行结果
接口调用超时:java.util.concurrent.TimeoutException最终结果:默认降级结果
completeOnTimeout ():超时返回默认值
completeOnTimeout() 与 orTimeout() 类似,但它不会抛出异常,而是在超时后直接返回一个默认值,任务状态标记为正常完成。
方法定义
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit)
  • value:超时后的默认返回值
  • timeout + unit :超时时间阈值
  • 超时后任务正常完成,不会触发 exceptionally()
实战示例:缓存查询的超时降级
import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit;public class CompleteOnTimeoutDemo {    private static final ExecutorService executor = Executors.newFixedThreadPool(2);    // 模拟缓存查询    private static CompletableFuture<StringqueryCache(String key) {        return CompletableFuture.supplyAsync(() -> {            try {                // 模拟缓存服务延迟                Thread.sleep(1500);            } catch (InterruptedException e) {                throw new RuntimeException(e);            }            return "缓存值:" + key;        }, executor);    }    public static void main(String[] args) {        CompletableFuture<String> future = queryCache("user_1001")                // 超时1秒返回默认值                .completeOnTimeout("缓存降级值"1TimeUnit.SECONDS);        System.out.println("最终结果:" + future.join());        executor.shutdown();    }}
运行结果
最终结果:缓存降级值
超时方法对比与最佳实践
特性
orTimeout()
completeOnTimeout()
超时行为
抛出 TimeoutException 异常
返回默认值,任务正常完成
异常处理触发
会触发 exceptionally()/handle()
不会触发异常处理 API
适用场景
需要明确感知超时异常的场景(如接口调用)
无需感知异常,直接降级的场景(如缓存查询)
最佳实践
  1. 接口调用优先用 orTimeout():可以捕获超时异常,记录详细日志,方便排查问题。
  2. 缓存 / 本地查询优先用 completeOnTimeout():简化代码,无需额外处理异常。
  3. 超时时间合理设置:根据业务场景设置,例如普通接口设为 1 秒,复杂接口设为 3 秒,避免过短或过长。
失败重试:提升异步任务的可靠性
在分布式系统中,异步任务可能会因为网络抖动 、 服务临时不可用等原因失败,此时需要重试机制来提升任务成功率。CompletableFuture 本身没有提供重试 API,但我们可以通过递归调用结合异常处理实现灵活的重试。
基础重试:固定次数 + 固定间隔
实现思路:在 exceptionally() 中判断异常类型和重试次数,未达到最大次数则递归调用原任务。
实战示例:远程接口的固定次数重试
import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit;public class RetryDemo1 {    private static final ExecutorService executor = Executors.newFixedThreadPool(2);    // 最大重试次数    private static final int MAX_RETRY = 3;    // 模拟远程接口调用,随机失败    private static CompletableFuture<StringcallApi(String url) {        return CompletableFuture.supplyAsync(() -> {            System.out.println("调用接口:" + url);            // 模拟50%概率失败            if (Math.random() > 0.5) {                throw new RuntimeException("接口调用失败");            }            return url + " 响应成功";        }, executor);    }    // 重试方法:递归实现    private static CompletableFuture<StringcallApiWithRetry(String url, int retryCount) {        return callApi(url)                .exceptionally(ex -> {                    // 判断是否达到最大重试次数                    if (retryCount >= MAX_RETRY) {                        System.out.println("达到最大重试次数,降级处理");                        return "接口降级结果";                    }                    // 重试间隔1秒                    try {                        TimeUnit.SECONDS.sleep(1);                    } catch (InterruptedException e) {                        throw new RuntimeException(e);                    }                    System.out.println("重试第" + (retryCount + 1) + "次");                    // 递归重试                    return callApiWithRetry(url, retryCount + 1).join();                });    }    public static void main(String[] args) {        CompletableFuture<String> future = callApiWithRetry("https://api.example.com"0);        System.out.println("最终结果:" + future.join());        executor.shutdown();    }}
运行结果(失败场景)
调用接口:https://api.example.com重试第1调用接口:https://api.example.com重试第2调用接口:https://api.example.com重试第3调用接口:https://api.example.com达到最大重试次数,降级处理最终结果:接口降级结果
高级重试:指数退避策略
固定间隔重试在高并发场景下可能会加剧服务压力(例如所有请求同时重试),更优雅的方式是使用指数退避策略 —— 重试间隔随重试次数指数增长(如 1s→2s→4s→8s)。
实战示例:指数退避重试
import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit;public class RetryDemo2 {    private static final ExecutorService executor = Executors.newFixedThreadPool(2);    private static final int MAX_RETRY = 3;    // 初始重试间隔    private static final long INITIAL_DELAY = 1000;    private static CompletableFuture<StringcallApi(String url) {        return CompletableFuture.supplyAsync(() -> {            System.out.println("调用接口:" + url);            if (Math.random() > 0.5) {                throw new RuntimeException("接口调用失败");            }            return url + " 响应成功";        }, executor);    }    // 指数退避重试    private static CompletableFuture<StringcallApiWithExponentialRetry(String url, int retryCount) {        return callApi(url)                .exceptionally(ex -> {                    if (retryCount >= MAX_RETRY) {                        System.out.println("达到最大重试次数,降级");                        return "降级结果";                    }                    // 指数退避:间隔 = 初始间隔 * (2^重试次数)                    long delay = INITIAL_DELAY * (1L << retryCount);                    try {                        System.out.println("等待" + delay + "ms后重试");                        TimeUnit.MILLISECONDS.sleep(delay);                    } catch (InterruptedException e) {                        throw new RuntimeException(e);                    }                    System.out.println("指数退避重试第" + (retryCount + 1) + "次");                    return callApiWithExponentialRetry(url, retryCount + 1).join();                });    }    public static void main(String[] args) {        CompletableFuture<String> future = callApiWithExponentialRetry("https://api.example.com"0);        System.out.println("最终结果:" + future.join());        executor.shutdown();    }}
运行结果
调用接口:https://api.example.com等待1000ms后重试指数退避重试第1调用接口:https://api.example.com等待2000ms后重试指数退避重试第2调用接口:https://api.example.com等待4000ms后重试指数退避重试第3调用接口:https://api.example.com达到最大重试次数,降级最终结果:降级结果
重试机制最佳实践
  1. 限制最大重试次数:避免无限重试导致的资源耗尽,建议设置 3~5 次。
  2. 使用指数退避策略:减少对下游服务的压力,避免雪崩效应。
  3. 区分异常类型:只对 临时性异常 (如网络超时、服务忙)重试,对 永久性异常 (如参数错误、权限不足)直接降级。
  4. 结合线程池隔离:重试任务使用独立线程池,避免影响主业务线程池。
CompletableFuture与Stream并行流的协同
Java 8 的 Stream 提供了并行流( parallelStream() )功能,底层同样基于 ForkJoinPool.commonPool() 。我们可以结合 CompletableFuture 实现更灵活的并行计算,解决并行流的一些局限性。
并行流的局限性
  1. 线程池不可控:并行流默认使用 ForkJoinPool.commonPool() ,与 CompletableFuture 共享线程池,容易引发资源竞争。
  2. 超时与异常处理弱:并行流没有内置的超时机制,异常处理不够灵活。
  3. 无法设置优先级:所有任务优先级相同,无法区分核心任务和非核心任务。
CompletableFuture 替代并行流:可控的并行计算
通过 CompletableFuture.supplyAsync() 结合 Stream ,可以实现自定义线程池的并行计算,同时支持超时和异常处理。
实战示例:批量数据并行处理
需求:批量查询 10 个用户的信息,每个查询耗时 500ms,要求总耗时不超过 1 秒。
import java.util.ArrayList;import java.util.List;import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.stream.Collectors;public class CompletableFutureWithStream {    // 自定义并行线程池    private static final ExecutorService PARALLEL_POOL = new ThreadPoolExecutor(            5,            10,            60L,            TimeUnit.SECONDS,            new ArrayBlockingQueue<>(100),            new BasicThreadFactory.Builder().namingPattern("parallel-thread-%d").build(),            new ThreadPoolExecutor.CallerRunsPolicy()    );    // 模拟查询单个用户信息    private static CompletableFuture<StringqueryUser(String userId) {        return CompletableFuture.supplyAsync(() -> {            try {                Thread.sleep(500);            } catch (InterruptedException e) {                throw new RuntimeException(e);            }            return "用户" + userId + "信息";        }, PARALLEL_POOL);    }    public static void main(String[] args) {        long start = System.currentTimeMillis();        // 构建用户ID列表        List<String> userIds = new ArrayList<>();        for (int i = 1; i <= 10; i++) {            userIds.add("" + i);        }        // 并行查询所有用户信息        List<CompletableFuture<String>> futureList = userIds.stream()                .map(userId -> queryUser(userId).orTimeout(1TimeUnit.SECONDS))                .collect(Collectors.toList());        // 等待所有任务完成并聚合结果        List<String> userList = futureList.stream()                .map(CompletableFuture::join)                .collect(Collectors.toList());        // 输出结果        System.out.println("用户信息列表:");        userList.forEach(System.out::println);        System.out.println("总耗时:" + (System.currentTimeMillis() - start) + "ms");        PARALLEL_POOL.shutdown();    }}
运行结果
用户信息列表:用户1信息用户2信息...用户10信息总耗时:1010ms
结果分析 :
  • 线程池核心线程数为 5,10 个任务分两批执行,每批 5 个,总耗时约 500*2=1000ms,符合预期。
  • 相比并行流,使用自定义线程池可以精确控制并发度,避免资源竞争。
协同使用最佳实践
  1. 并行流适用于简单场景:如果任务简单、无依赖、不需要超时控制,并行流更简洁。
  2. CompletableFuture 适用于复杂场景:需要自定义线程池、超时控制、重试机制时,优先使用 CompletableFuture。
  3. 避免并行流与 CompletableFuture 混用:两者默认共享 commonPool ,容易导致资源竞争,建议统一使用自定义线程池。
异步任务编排模式
在复杂业务场景中,我们需要对多个异步任务进行编排,常见的编排模式有串行编排 、 并行编排 、 聚合编排 、 分支编排等。
串行编排
  • 适用场景:任务之间有依赖关系,如订单→商品→品牌的多级查询。
  • 实现方式:使用 thenCompose() 或 thenApplyAsync() 实现链式调用。
  • 核心优势:代码简洁,结果自动传递,支持异常降级。
并行编排
  • 适用场景:任务之间无依赖,需要并行执行以缩短总耗时,如电商首页多源数据查询。
  • 实现方式:使用 CompletableFuture.allOf() 结合自定义线程池。
  • 核心优势:充分利用多核 CPU,总耗时等于最慢任务的耗时。
聚合编排
  • 适用场景:需要聚合多个任务的结果,支持部分任务失败降级,如批量查询用户信息。
  • 实现方式:使用 handle() 对每个任务的结果进行处理,再聚合。
  • 核心优势:容错性高,部分任务失败不影响整体结果。
分支编排
  • 适用场景:根据不同条件执行不同的异步任务,如根据用户等级查询不同的会员权益。
  • 实现方式:结合 if-else 或 switch ,动态创建不同的 CompletableFuture 任务。
  • 实战示例
import java.util.concurrent.CompletableFuture;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;public class BranchOrchestrationDemo {    private static final ExecutorService executor = Executors.newFixedThreadPool(2);    static class User {        private String userId;        private int level;        public User(String userId, int level) {            this.userId = userId;            this.level = level;        }        public int getLevel() {            return level;        }    }    // 普通会员权益查询    private static CompletableFuture<StringqueryNormalRights() {        return CompletableFuture.supplyAsync(() -> "普通会员:无折扣", executor);    }    // 高级会员权益查询    private static CompletableFuture<StringqueryVipRights() {        return CompletableFuture.supplyAsync(() -> "高级会员:9折优惠", executor);    }    public static void main(String[] args) {        User user = new User("1001"2); // 2级为高级会员        // 分支编排:根据用户等级选择不同任务        CompletableFuture<String> rightsFuture = user.getLevel() >= 2                ? queryVipRights()                : queryNormalRights();        System.out.println("会员权益:" + rightsFuture.join());        executor.shutdown();    }}
运行结果
高级会员:9折优惠
高级特性总结与实战建议
核心知识点总结
  1. 超时控制: orTimeout() 抛异常, completeOnTimeout() 返默认值,根据场景选择。
  2. 失败重试:通过递归 + exceptionally() 实现,推荐指数退避策略。
  3. 与并行流结合:复杂场景用 CompletableFuture + 自定义线程池,简单场景用并行流。
  4. 任务编排:串行用 thenCompose() ,并行用 allOf() ,聚合用 handle() ,分支用条件判断。
实战建议
优先使用自定义线程池:避免默认线程池的资源竞争问题。
超时 + 重试 + 降级 三板斧:提升异步任务的稳定性和容错性。
合理选择编排模式:根据任务依赖关系选择对应的 API,避免过度设计。
加强监控与日志:记录任务的执行时间、重试次数、异常信息,方便问题排查。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 18:31:50 HTTP/2.0 GET : https://f.mffb.com.cn/a/472570.html
  2. 运行时间 : 0.170626s [ 吞吐率:5.86req/s ] 内存消耗:4,773.70kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=52d83fa77fd595c7418a12f0585cecfd
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000481s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000951s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.005454s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.013121s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000888s ]
  6. SELECT * FROM `set` [ RunTime:0.003950s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000912s ]
  8. SELECT * FROM `article` WHERE `id` = 472570 LIMIT 1 [ RunTime:0.000788s ]
  9. UPDATE `article` SET `lasttime` = 1770460310 WHERE `id` = 472570 [ RunTime:0.005020s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 65 LIMIT 1 [ RunTime:0.010238s ]
  11. SELECT * FROM `article` WHERE `id` < 472570 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.008927s ]
  12. SELECT * FROM `article` WHERE `id` > 472570 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001152s ]
  13. SELECT * FROM `article` WHERE `id` < 472570 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000790s ]
  14. SELECT * FROM `article` WHERE `id` < 472570 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.008868s ]
  15. SELECT * FROM `article` WHERE `id` < 472570 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.009460s ]
0.172193s