Falcor如何在服务器端缓存数据? [英] How does Falcor cache data in the server side?

查看:89
本文介绍了Falcor如何在服务器端缓存数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,在falcor客户端中,它会将数据缓存在模型中.在应用程序服务器端,我们需要实现falcor路由作为数据源. Falcor是否在应用程序服务器端缓存数据?如果是这样,怎么办? 谢谢,

I understand that in the falcor client side, it caches data in the model. On the application server side, we need to implement falcor routes as data source. Does Falcor cache data in the application server side? If so, how? Thanks,

推荐答案

总之,不,falcor-router不会缓存数据.由于单个请求可能由多个路由解决,因此路由器确实会建立每个请求的缓存,但是在路由器完成对请求的响应后,该缓存将被丢弃.

In short, no, the falcor-router does not cache data. 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.

例如以下请求

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

可以通过两条或三种不同的路线来解决,例如

could be resolved by two or three different routes, e.g.

[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.

这意味着几件事:

  • 服务器不知道客户端上是否有什么数据
  • 图片段未实现,这意味着运行相同的查询两次(假设它没有到达falcor客户端模型的缓存)将运行相同的查询.

服务器端缓存和缓存失效更适合在数据库层而不是路由器层中处理

Server-side caching and cache invalidation is more appropriately handled in a database layer, rather than the router layer

这篇关于Falcor如何在服务器端缓存数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆