Cache
API 参考
Cache
签名
constructor(options: Cache.Options): Cache例子
import { List, Cache } from "@raycast/api";
type Item = { id: string; title: string };
const cache = new Cache();
cache.set("items", JSON.stringify([{ id: "1", title: "Item 1" }]));
export default function Command() {
const cached = cache.get("items");
const items: Item[] = cached ? JSON.parse(cached) : [];
return (
<List>
{items.map((item) => (
<List.Item key={item.id} title={item.title} />
))}
</List>
);
}属性
名称
描述
类型
方法
方法
Cache#get
签名
参数
名称
描述
类型
Cache#has
签名
参数
名称
描述
类型
Cache#set
签名
参数
名称
描述
Type
Cache#remove
签名
Cache#clear
签名
参数
名称
描述
类型
Cache#subscribe
签名
参数
名称
描述
类型
类型
Cache.Options
属性
名称
描述
类型
Cache.Subscriber
Cache.Subscription
最后更新于