当前位置:首页>python>Python 并发与 asyncio 10.3 实现商品列表接口

Python 并发与 asyncio 10.3 实现商品列表接口

  • 2026-01-29 18:15:28
Python 并发与 asyncio 10.3 实现商品列表接口

10.3 实现商品列表接口

我们来构建一个「全部商品」页面的后端服务,对应桌面端的体验。这个页面要展示所有商品,同时显示用户购物车和收藏夹状态,还有库存不足提示。

图10.2 是原型示意。

图10.2 商品列表页原型图

在这种架构下,我们需要从几个独立服务获取数据,再拼在一起。先来看看我们需要哪些基础服务和数据模型:

10.3.1 用户收藏服务

这个服务记录每个用户收藏了哪些商品。下面这几个服务也都会用到:

  • 用户购物车服务(同收藏逻辑)
  • 库存服务
  • 商品服务
购物车服务:用户 → 商品的映射关系,数据模型和收藏服务一样。 库存服务:商品 → 可售数量的映射。 商品服务:商品详情(名称、规格等),类似第9章的数据库服务。

10.3.2 实现基础服务

先写个最简单的库存服务,我们用 aiohttp 搭个框架,模拟一下返回库存数据。为了演示效果,我们随机生成0-100之间的数字,还故意加了随机延迟,模拟网络抖动。

服务启动在 8001 端口,和之前的商品服务(8000)不冲突。

# Listing 10.1 库存服务import asyncioimport randomfrom aiohttp import webfrom aiohttp.web_response import Responseroutes = web.RouteTableDef()@routes.get('/products/{id}/inventory')async def get_inventory(request: Request) -> Response:    delay: int = random.randint(05)    await asyncio.sleep(delay)    inventory: int = random.randint(0100)    return web.json_response({'inventory': inventory})app = web.Application()app.add_routes(routes)web.run_app(app, port=8001)

接下来实现用户购物车和收藏服务。这两个表结构一样,所以我们直接复用代码,只改表名。

创建表:

-- Listing 10.2 购物车表CREATE TABLE user_cart(    user_id    INT NOT NULL,    product_id INT NOT NULL);INSERT INTO user_cart VALUES(11);INSERT INTO user_cart VALUES(12);INSERT INTO user_cart VALUES(13);INSERT INTO user_cart VALUES(21);INSERT INTO user_cart VALUES(22);INSERT INTO user_cart VALUES(25);
-- Listing 10.3 收藏表CREATE TABLE user_favorite(    user_id    INT NOT NULL,    product_id INT NOT NULL);INSERT INTO user_favorite VALUES(11);INSERT INTO user_favorite VALUES(12);INSERT INTO user_favorite VALUES(13);INSERT INTO user_favorite VALUES(31);INSERT INTO user_favorite VALUES(32);INSERT INTO user_favorite VALUES(33);

由于我们想模拟多数据库,要把两个表分别放在不同的 Postgres 数据库里。可以用命令行创建:

sudo -u postgres psql -c "CREATE DATABASE cart;"sudo -u postgres psql -c "CREATE DATABASE favorites;"

为避免频繁连接数据库,我们封装一个通用的连接池工具,后面会用在 on_startup / on_cleanup 钩子里。

# Listing 10.4 创建和销毁数据库连接池import asyncpgfrom aiohttp.web_app import Applicationfrom asyncpg.pool import PoolDB_KEY = 'database'async def create_database_pool(app: Application,                               host: str,                               port: int,                               user: str,                               database: str,                               password: str):    pool: Pool = await asyncpg.create_pool(host=host,                                           port=port,                                           user=user,                                           password=password,                                           database=database,                                           min_size=6,                                           max_size=6)    app[DB_KEY] = poolasync def destroy_database_pool(app: Application):    pool: Pool = app[DB_KEY]    await pool.close()

上面这段代码就跟第五章差不多,create_database_pool 创建连接池并挂载到 App;destroy_database_pool 则关闭连接池。

接着我们写服务。因为收藏和购物车都是用户的子资源,所以路径格式是 /users/{id}/favorites 这种。

先写用户收藏服务

# Listing 10.5 收藏服务import functoolsfrom aiohttp import webfrom aiohttp.web_request import Requestfrom aiohttp.web_response import Responsefrom chapter_10.listing_10_4 import DB_KEY, create_database_pool, destroy_database_poolroutes = web.RouteTableDef()@routes.get('/users/{id}/favorites')async def favorites(request: Request) -> Response:    try:        str_id = request.match_info['id']        user_id = int(str_id)        db = request.app[DB_KEY]        favorite_query = 'SELECT product_id from user_favorite where user_id = $1'        result = await db.fetch(favorite_query, user_id)        if result is not None:            return web.json_response([dict(record) for record in result])        else:            raise web.HTTPNotFound()    except ValueError:        raise web.HTTPBadRequest()app = web.Application()app.on_startup.append(functools.partial(create_database_pool,                                        host='127.0.0.1',                                        port=5432,                                        user='postgres',                                        password='password',                                        database='favorites'))app.on_cleanup.append(destroy_database_pool)app.add_routes(routes)web.run_app(app, port=8002)

再写购物车服务,几乎一样,只是改成了 user_cart 表:

# Listing 10.6 购物车服务import functoolsfrom aiohttp import webfrom aiohttp.web_request import Requestfrom aiohttp.web_response import Responsefrom chapter_10.listing_10_4 import DB_KEY, create_database_pool, destroy_database_poolroutes = web.RouteTableDef()@routes.get('/users/{id}/cart')async def time(request: Request) -> Response:    try:        str_id = request.match_info['id']        user_id = int(str_id)        db = request.app[DB_KEY]        favorite_query = 'SELECT product_id from user_cart where user_id = $1'        result = await db.fetch(favorite_query, user_id)        if result is not None:            return web.json_response([dict(record) for record in result])        else:            raise web.HTTPNotFound()    except ValueError:        raise web.HTTPBadRequest()app = web.Application()app.on_startup.append(functools.partial(create_database_pool,                                        host='127.0.0.1',                                        port=5432,                                        user='postgres',                                        password='password',                                        database='cart'))app.on_cleanup.append(destroy_database_pool)app.add_routes(routes)web.run_app(app, port=8003)

最后写商品服务,和第9章类似,但这次查询的是所有商品:

# Listing 10.7 商品服务import functoolsfrom aiohttp import webfrom aiohttp.web_request import Requestfrom aiohttp.web_response import Responsefrom chapter_10.listing_10_4 import DB_KEY, create_database_pool, destroy_database_poolroutes = web.RouteTableDef()@routes.get('/products')async def products(request: Request) -> Response:    db = request.app[DB_KEY]    product_query = 'SELECT product_id, product_name FROM product'    result = await db.fetch(product_query)    return web.json_response([dict(record) for record in result])app = web.Application()app.on_startup.append(functools.partial(create_database_pool,                                        host='127.0.0.1',                                        port=5432,                                        user='postgres',                                        password='password',                                        database='products'))app.on_cleanup.append(destroy_database_pool)app.add_routes(routes)web.run_app(app, port=8000)

好了,四个基础服务都搭好了,现在开始打造我们的「前端后端」服务。

10.3.3 实现前端后端服务

先明确需求:商品加载速度至关重要。用户等得越久,就越不想继续逛,购买意愿也越低。所以我们追求的是:在最短时间内返回最少必要数据

具体要求如下:

  • 商品服务最多等1秒。超时就返回504错误,不让前端一直卡着。
  • 购物车和收藏数据是可选的。如果能在1秒内拿到,就返回;否则就放弃,直接给商品数据。
  • 库存数据也是可选。拿不到就只返回商品信息。

这么一来,即使某个服务崩溃或网络超时,咱们的接口也能“活着”返回有用信息,用户不至于看到一个永远转圈的进度条。

那么我们期望返回的数据长啥样?

{ "cart_items": 1, "favorite_items": null, "products": [   {"product_id": 4, "inventory": 4},   {"product_id": 3, "inventory": 65} ]}

解释一下:用户购物车有1个商品;收藏数据拿不到,返回 null;有两个商品要展示,库存分别是4和65件。

怎么实现呢?思路是:

  • 用 aiohttp 的客户端发起多个并行请求。
  • 使用 asyncio.wait 同时发起请求,设超时1秒。
  • 一旦超时或出现异常,立刻取消未完成请求,快速响应。
  • 如果商品数据成功,再并行拉库存,同样带超时。

关键来了,要先确认商品数据(这是主干),才能决定是否拉库存。所以我们在 all_products 中这样做:

# Listing 10.8 商品前端后端服务import asynciofrom asyncio import Taskimport aiohttpfrom aiohttp import web, ClientSessionfrom aiohttp.web_request import Requestfrom aiohttp.web_response import Responseimport loggingfrom typing import DictSet, Awaitable, OptionalListroutes = web.RouteTableDef()PRODUCT_BASE = 'http://127.0.0.1:8000'INVENTORY_BASE = 'http://127.0.0.1:8001'FAVORITE_BASE = 'http://127.0.0.1:8002'CART_BASE = 'http://127.0.0.1:8003'@routes.get('/products/all')async def all_products(request: Request) -> Response:    async with aiohttp.ClientSession() as session:        products = asyncio.create_task(session.get(f'{PRODUCT_BASE}/products'))        favorites = asyncio.create_task(session.get(f'{FAVORITE_BASE}/users/3/favorites'))        cart = asyncio.create_task(session.get(f'{CART_BASE}/users/3/cart'))        requests = [products, favorites, cart]        done, pending = await asyncio.wait(requests, timeout=1.0)  # ❶        if products in pending:  # ❷            [request.cancel() for request in requests]            return web.json_response({'error''Could not reach products service.'}, status=504)        elif products in done and products.exception() is not None:            [request.cancel() for request in requests]            logging.exception('Server error reaching product service.', exc_info=products.exception())            return web.json_response({'error''Server error reaching products service.'}, status=500)        else:            product_response = await products.result().json()  # ❸            product_results: List[Dict] = await get_products_with_inventory(session, product_response)            cart_item_count: Optional[int] = await get_response_item_count(cart,                                                                           done,                                                                           pending,                                                                           'Error getting user cart.')            favorite_item_count: Optional[int] = await get_response_item_count(favorites,                                                                               done,                                                                               pending,                                                                               'Error getting user favorites.')            return web.json_response({'cart_items': cart_item_count,                                      'favorite_items': favorite_item_count,                                      'products': product_results})

函数 get_products_with_inventory 和 get_response_item_count 也都要写:

async def get_products_with_inventory(session: ClientSession,                      product_response) -> List[Dict]:    def get_inventory(session: ClientSession, product_id: str) -> Task:        url = f"{INVENTORY_BASE}/products/{product_id}/inventory"        return asyncio.create_task(session.get(url))    def create_product_record(product_id: int, inventory: Optional[int]) -> Dict:        return {'product_id': product_id, 'inventory': inventory}    inventory_tasks_to_product_id = {        get_inventory(session, product['product_id']): product['product_id']        for product in product_response    }    inventory_done, inventory_pending = await asyncio.wait(inventory_tasks_to_product_id.keys(), timeout=1.0)    product_results = []    for done_task in inventory_done:        if done_task.exception() is None:            product_id = inventory_tasks_to_product_id[done_task]            inventory = await done_task.result().json()            product_results.append(create_product_record(product_id, inventory['inventory']))        else:            product_id = inventory_tasks_to_product_id[done_task]            product_results.append(create_product_record(product_id, None))            logging.exception(f'Error getting inventory for id {product_id}',                              exc_info=inventory_tasks_to_product_id[done_task].exception())    for pending_task in inventory_pending:        pending_task.cancel()        product_id = inventory_tasks_to_product_id[pending_task]        product_results.append(create_product_record(product_id, None))    return product_resultsasync def get_response_item_count(task: Task,                                  done: Set[Awaitable],                                  pending: Set[Awaitable],                                  error_msg: str) -> Optional[int]:    if task in done and task.exception() is None:        return len(await task.result().json())    elif task in pending:        task.cancel()    else:        logging.exception(error_msg, exc_info=task.exception())    return None
  • ❶:并行发起三个请求,超时1秒。
  • ❷:如果商品服务超时,直接报504,不再等待。
  • ❸:拿到商品数据后,开始批量请求库存。

这套逻辑非常实用:即便某个服务雪崩,也能快速返回部分内容,让用户至少看到点东西

10.3.4 失败请求重试机制

上面这个版本有个小缺点:一出错就“认输”,直接放弃。但实际上很多问题是瞬时的,比如临时网络波动、负载均衡器抖动,过一会儿就好了。

这个时候,我们可以试试“重试”:失败后短暂等待,再试一次。

asyncio.wait_for 就是好工具,它支持超时,失败就抛异常。我们可以封装一个通用的 retry 协程:

# Listing 10.9 重试协程import asyncioimport loggingfrom typing import Callable, Awaitableclass TooManyRetries(Exception):    passasync def retry(coro: Callable[[], Awaitable],                max_retries: int,                timeout: float,                retry_interval: float):    for retry_num in range(0, max_retries):        try:            return await asyncio.wait_for(coro(), timeout=timeout)  # ❶        except Exception as e:            logging.exception(f'Exception while waiting (tried {retry_num} times), retrying.', exc_info=e)  # ❷            await asyncio.sleep(retry_interval)    raise TooManyRetries()  # ❸

验证一下:

# Listing 10.10 测试重试import asynciofrom chapter_10.listing_10_9 import retry, TooManyRetriesasync def main():    async def always_fail():        raise Exception("I've failed!")    async def always_timeout():        await asyncio.sleep(1)    try:        await retry(always_fail,                    max_retries=3,                    timeout=.1,                    retry_interval=.1)    except TooManyRetries:        print('Retried too many times!')    try:        await retry(always_timeout,                    max_retries=3,                    timeout=.1,                    retry_interval=.1)    except TooManyRetries:        print('Retried too many times!')asyncio.run(main())

运行后你会看到两条报错信息,最后打印出“Retried too many times!”。说明重试机制生效了。

我们可以把重试加到原始请求里:

product_request = functools.partial(session.get, f'{PRODUCT_BASE}/products')favorite_request = functools.partial(session.get, f'{FAVORITE_BASE}/users/5/favorites')cart_request = functools.partial(session.get, f'{CART_BASE}/users/5/cart')products = asyncio.create_task(retry(product_request,                                     max_retries=3,                                     timeout=.1,                                     retry_interval=.1))favorites = asyncio.create_task(retry(favorite_request,                                      max_retries=3,                                      timeout=.1,                                      retry_interval=.1))cart = asyncio.create_task(retry(cart_request,                                 max_retries=3,                                 timeout=.1,                                 retry_interval=.1))requests = [products, favorites, cart]done, pending = await asyncio.wait(requests, timeout=1.0)

这样改完,遇到偶尔失败也不慌,最多尝试3次,大大提高了容错率。

不过还是有个潜在问题:如果某个服务一直超时,岂不是每次都重试,白白浪费用户时间?

10.3.5 熔断器模式

这才是真正的“防崩神器”——熔断器(circuit breaker)

当某个服务持续超时或出错,比如用户收藏服务总是1秒才返回,那所有用户都会被拖死。

这时,我们该“跳闸”了!让它像电闸一样自动断开,拒绝所有请求,直接返回错误,防止用户一直在等

这就是熔断器的核心思想:

  • 闭合(closed):正常走流程。
  • 开启(open):出错次数超过阈值,立刻拦截请求。
  • 半开(half-open):过一段时间后允许一次请求探路,若恢复则关闭熔断。

我们可以简化实现,暂时忽略“半开”状态,只做“闭合→开启”切换。

# Listing 10.11 简易熔断器import asynciofrom datetime import datetime, timedeltaclass CircuitOpenException(Exception):    passclass CircuitBreaker:    def __init__(self,                 callback,                 timeout: float,                 time_window: float,                 max_failures: int,                 reset_interval: float):        self.callback = callback        self.timeout = timeout        self.time_window = time_window        self.max_failures = max_failures        self.reset_interval = reset_interval        self.last_request_time = None        self.last_failure_time = None        self.current_failures = 0    async def request(self, *args, **kwargs):  # ❶        if self.current_failures >= self.max_failures:            if datetime.now() > self.last_request_time + timedelta(seconds=self.reset_interval):                self._reset('Circuit is going from open to closed, resetting!')                return await self._do_request(*args, **kwargs)            else:                print('Circuit is open, failing fast!')                raise CircuitOpenException()        else:            if self.last_failure_time and datetime.now() > self.last_failure_time + timedelta(seconds=self.time_window):                self._reset('Interval since first failure elapsed, resetting!')            print('Circuit is closed, requesting!')            return await self._do_request(*args, **kwargs)    def _reset(self, msg: str):  # ❷        print(msg)        self.last_failure_time = None        self.current_failures = 0    async def _do_request(self, *args, **kwargs):  # ❸        try:            print('Making request!')            self.last_request_time = datetime.now()            return await asyncio.wait_for(self.callback(*args, **kwargs), timeout=self.timeout)        except Exception as e:            self.current_failures = self.current_failures + 1            if self.last_failure_time is None:                self.last_failure_time = datetime.now()            raise

测试:

# Listing 10.12 熔断器实战import asynciofrom chapter_10.listing_10_11 import CircuitBreakerasync def main():    async def slow_callback():        await asyncio.sleep(2)    cb = CircuitBreaker(slow_callback,                        timeout=1.0,                        time_window=5,                        max_failures=2,                        reset_interval=5)    for _ in range(4):        try:            await cb.request()        except Exception as e:            pass    print('Sleeping for 5 seconds so breaker closes...')    await asyncio.sleep(5)    for _ in range(4):        try:            await cb.request()        except Exception as e:            passasyncio.run(main())

输出可见,前两次触发超时,然后进入“熔断状态”,后续请求直接失败。等5秒后,“熔断器”自动复位,再次恢复。

现在我们把它用在库存服务上,让其更稳定:

async def get_inventory(session: ClientSession, product_id: str):    url = f"{INVENTORY_BASE}/products/{product_id}/inventory"    return await session.get(url)inventory_circuit = CircuitBreaker(get_inventory, timeout=.5, time_window=5.0, max_failures=3, reset_interval=30)

然后在 all_products 里这样调用:

inventory_tasks_to_pid = {    asyncio.create_task(inventory_circuit.request(session, product['product_id'])): product['product_id']    for product in product_response}inventory_done, inventory_pending = await asyncio.wait(inventory_tasks_to_pid.keys(), timeout=1.0)

这样一来,一旦库存服务扛不住,我们就“手动跳闸”,后续请求直接拒绝,用户也不会傻等了。

小结

  • 微服务相比单体,优势明显:独立部署、灵活扩展。
  • “前端后端”模式能合并多个接口,优化用户体验。
  • asyncio.wait 能实现并发拉取+超时控制,让服务更稳健。
  • 自定义重试机制可提升网络稳定性。
  • 熔断器模式是防雪崩的关键,真正做到了“不求完美,但求不死”。

这套组合拳下来,你的系统不仅快,还耐打!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 07:05:41 HTTP/2.0 GET : https://f.mffb.com.cn/a/468647.html
  2. 运行时间 : 0.205312s [ 吞吐率:4.87req/s ] 内存消耗:4,642.54kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=488082d14c4e83926b0ff704791bd274
  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.000905s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001413s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000733s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000675s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001292s ]
  6. SELECT * FROM `set` [ RunTime:0.000625s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001443s ]
  8. SELECT * FROM `article` WHERE `id` = 468647 LIMIT 1 [ RunTime:0.002166s ]
  9. UPDATE `article` SET `lasttime` = 1770505542 WHERE `id` = 468647 [ RunTime:0.015401s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000677s ]
  11. SELECT * FROM `article` WHERE `id` < 468647 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001044s ]
  12. SELECT * FROM `article` WHERE `id` > 468647 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001640s ]
  13. SELECT * FROM `article` WHERE `id` < 468647 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.013463s ]
  14. SELECT * FROM `article` WHERE `id` < 468647 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001997s ]
  15. SELECT * FROM `article` WHERE `id` < 468647 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001933s ]
0.209070s