I have a CodeIgniter project. I want to use Memcache, but I don't w开发者_Python百科ant to create a new
connection every time index.php
is loaded (which is on every page load). How can I set up Apache / CodeIgniter so that I always have access to a memcache connection, without having to re-establish it all the time?
Sorry, the thing about php/apache is, it sets up and tears down the entire environment every time. There is no application level persistence, other than external to the php/apache env (i.e. file, database, or memcache). You have to set up the new connection every time you want to use it. Of course, PHP makes up for this by doing it all blisteringly fast, and that is the tradeoff the developers of the PHP runtime choose to make.
精彩评论