简体   繁体   English

Falcor如何在服务器端缓存数据?

[英]How does Falcor cache data in the server side?

I understand that in the falcor client side, it caches data in the model. 我了解到,在falcor客户端中,它会将数据缓存在模型中。 On the application server side, we need to implement falcor routes as data source. 在应用程序服务器端,我们需要实现falcor路由作为数据源。 Does Falcor cache data in the application server side? Falcor是否在应用程序服务器端缓存数据? If so, how? 如果是这样,怎么办? Thanks, 谢谢,

In short, no, the falcor-router does not cache data. 简而言之,不,falcor路由器不缓存数据。 Because a single request might be resolved by multiple routes, the router does build a per-request cache, but that cache is dropped after the router finishes responding to the request. 由于单个请求可能由多个路由解决,因此路由器确实会建立每个请求的缓存,但是在路由器完成对请求的响应后,该缓存将被丢弃。

Eg the following request 例如以下要求

method=get
paths=[
  items[0..10]['id', 'name'],
  items.length,
]

could be resolved by two or three different routes, eg 可以通过两条或三种不同的路线来解决,例如

[items[{range}]]
[items.length]
[itemsById[{keys}]

The router will merge each route response into a graph fragment until it resolves all requested paths and follows up any returned ref nodes. 路由器会将每个路由响应合并到一个图形片段中,直到解析所有请求的路径并跟踪所有返回的引用节点。 This graph fragment can be thought of as a per-request cache (or at least, it's referred to as such in the source code ), but it is dropped after the response is returned to the client. 可以将这个图片段视为每个请求的缓存(或者至少在源代码中称为),但是在响应返回给客户端之后将其删除。

This implies a few things: 这意味着几件事:

  • the server has no knowledge of what data is/isn't already on a client 服务器不知道客户端上已经/没有什么数据
  • graph fragments are not materialized, meaning running the same query twice (assuming it doesn't hit your falcor client model's cache) will run the same query. 图形片段没有实现,这意味着运行相同的查询两次(假设它没有到达falcor客户端模型的缓存)将运行相同的查询。

Server-side caching and cache invalidation is more appropriately handled in a database layer, rather than the router layer 服务器端缓存和缓存失效更适合在数据库层而不是路由器层中处理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM