Is it acceptable to keep a db connection open for the life of the page?

前端 未结 10 2009
执念已碎
执念已碎 2021-01-18 07:11

Everybody knows that you should close a connection immediately after you finish using it.

Due to a flaw in my domain object model design, I\'ve had to leave the conn

10条回答
  •  长发绾君心
    2021-01-18 07:40

    It's not ideal but I wouldn't re-write my application over it. Unless your page is doing a large amount of time-consuming work in various methods, the whole page lifecycle should execute quickly. In practice it may just mean that your connection object is open a few milliseconds longer than it would have been otherwise. That might be significant in some scenarios, but it doesn't sound like it would be in your case.

提交回复
热议问题