跳到主要内容

控件缓存 (Selector.cache)

Selector.cache

声明

Selector.cache(is_cache)

参数

参数类型是否必填说明
is_cachebooleantrue=打开缓存,缓存当前页面所有控件;false=关闭缓存

说明

是否启用控件缓存机制。

待实现

该接口正在开发中。

注意

启用后,控件将不再刷新,请及时释放缓存。启用后,查找速度将有大幅度提升。

示例

local node = require("node")

-- 开启缓存
Selector.cache(true)

-- 执行多次查找(使用缓存,速度快)
local node1 = node.selector():id("btn1"):find()
local node2 = node.selector():id("btn2"):find()
local node3 = node.selector():text("确定"):find()

-- 关闭缓存
Selector.cache(false)

AScript 对应

# AScript (Python)
from ascript.android.node import Selector

Selector.cache(True) # 开启缓存
Selector.cache(False) # 关闭缓存