That's a somewhat odd question to ask for a programming language that - by design - shares nothing and recreates the entire environment on each request anyway.
When talking about cost, you have to take into account that finding and recreating the session data on each request takes up resources too. I don't know how many relations we are talking about in your app, but attaching all required subjects with observers in a bootstrap sounds like a clean and valid approach to me. You could push the responsibility for this into a manager class for increased maintainability.
发布评论
评论(2)
对于一种编程语言来说,这是一个有点奇怪的问题,它在设计上不共享任何内容,并且无论如何都会根据每个请求重新创建整个环境。
在谈论成本时,您必须考虑到在每个请求上查找和重新创建会话数据也会占用资源。我不知道我们在您的应用程序中讨论了多少关系,但在引导程序中将所有必需的主题与观察者附加在一起对我来说听起来是一种干净有效的方法。您可以将此责任推入经理类以提高可维护性。
如果对性能有疑问,请进行基准测试。
That's a somewhat odd question to ask for a programming language that - by design - shares nothing and recreates the entire environment on each request anyway.
When talking about cost, you have to take into account that finding and recreating the session data on each request takes up resources too. I don't know how many relations we are talking about in your app, but attaching all required subjects with observers in a bootstrap sounds like a clean and valid approach to me. You could push the responsibility for this into a manager class for increased maintainability.
If in doubt about performance, benchmark.
重新建立关系本身可能会花费最少的时间,因为对象是作为引用传递的。
The recreation of the relationships themselves would probably take the least amount of time, since the objects are passed around as references.