如何在asp.net mvc应用程序中构建一次图表并在后续请求中访问它

时间:2022-05-07 06:14:31

I am building an asp.net MVC application which searches a graph data structure to fulfill user's requests. I want to build this graph data structure on first request from database and then on requests after first request I want to use the previously built graph rather than building it again.

我正在构建一个asp.net MVC应用程序,它搜索图形数据结构以满足用户的请求。我想在第一次请求时从数据库构建这个图形数据结构,然后在第一次请求之后对请求构建我想要使用先前构建的图形而不是再次构建它。

but I do not know where to store the graph on first request so it can be accessed on subsequent requests.

但我不知道在第一次请求时将图表存储在何处,因此可以在后续请求中访问它。

1 个解决方案

#1


1  

I think you could consider storing it in your DB, and this would require you to store your graph in two separate tables: one for Nodes and one for Paths. You should have start_node_id and end_node_id in Paths, both being foreign keys referring to Nodes. As nodes can be connected with variable numbers of nodes, I believe creating multiple columns referring neigbouring nodes in Nodes makes no sense at all, as it would mean lots of NULL neighbours and limiting maximum neighbours count.

我认为您可以考虑将其存储在数据库中,这需要您将图形存储在两个单独的表中:一个用于节点,一个用于路径。你应该在Paths中有start_node_id和end_node_id,它们都是引用节点的外键。由于节点可以与可变数量的节点连接,我相信创建多个列引用节点中的邻接节点根本没有意义,因为它意味着许多NULL邻居并限制最大邻居数。

#1


1  

I think you could consider storing it in your DB, and this would require you to store your graph in two separate tables: one for Nodes and one for Paths. You should have start_node_id and end_node_id in Paths, both being foreign keys referring to Nodes. As nodes can be connected with variable numbers of nodes, I believe creating multiple columns referring neigbouring nodes in Nodes makes no sense at all, as it would mean lots of NULL neighbours and limiting maximum neighbours count.

我认为您可以考虑将其存储在数据库中,这需要您将图形存储在两个单独的表中:一个用于节点,一个用于路径。你应该在Paths中有start_node_id和end_node_id,它们都是引用节点的外键。由于节点可以与可变数量的节点连接,我相信创建多个列引用节点中的邻接节点根本没有意义,因为它意味着许多NULL邻居并限制最大邻居数。