首页 > 解决方案 > 中继现代缓存与存储

问题描述

通读中继文档,我对网络层(https://facebook.github.io/relay/docs/en/network-layer.html)与中继存储(https:// facebook.github.io/relay/docs/en/relay-store.html)。

这是两个不同的缓存吗?哪一个会自动获得 Relay 收集的垃圾?

标签: graphqlrelayrelaymodern

解决方案


@anon 网络层是您将客户端连接到 GraphQL 服务器、在应用程序上创建存储以缓存数据的方式。第二个链接更多地是关于如何在运行突变后更新store使用函数。updater

正如您在第一个链接中看到的:

// Create a network layer from the fetch function
const network = Network.create(fetchQuery);
const store = new Store(new RecordSource())

您正在使用relay-runtime包创建网络层/存储。

希望能帮助到你 :)


推荐阅读