Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beego 的 MVC 架构控制器创建问题 #975

Open
leellun opened this issue Apr 28, 2024 · 0 comments
Open

beego 的 MVC 架构控制器创建问题 #975

leellun opened this issue Apr 28, 2024 · 0 comments

Comments

@leellun
Copy link

leellun commented Apr 28, 2024

每一次请求都要去实例化一个控制器,是不是太奢侈了,作者是不是可以参考一下spring bean的声明周期,或者gin的参考下,每一次请求都去创建一个controller,个人觉得不是太有必要,开发中很少有把状态化数据对象放到controller上,如果有也多半是程序员的不规范,可以选择多种模式,spring的singleton、request或者prototype等多种模式,至少提供一种单例控制器。
好处:
(1)减少资源浪费,提升性能
(2)结合市面上的依赖注入全局管理所有controller、service、dao以及其它结构体实例
(3)规范化代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant