Does this caching issue still exist in CI 2.x? |
[eluser]SneakyDave[/eluser]
Regarding this old thread: http://ellislab.com/forums/viewthread/87567/ I found out that my installation of CI 1.7.2 and 1.7.3 was caching queries to the session table if DB caching was turned on. Naturally, this caused a lot of problems because there wasn't any code in the sessions class to turn caching off when selecting from the session table. I can turn off caching in the controller, but it doesn't solve the problem because the session class has already done it's work in bringing the session into the controller. Does this still exist in CI 2.0x? Or is there a reason it hasn't been fixed, or is there some other problem? I can verify that the problem is with the db caching because on page refreshes, the session class is loaded, but there aren't any queries done to the database, so it must be picking up the cached session, which may or may not look anything like the session stored on the table. Just confused. Thanks for any help.
[eluser]SneakyDave[/eluser]
The best way to fix this for me after a lot of trial and error is this: If you use sessions and store them in a session table described in database.php as $config['sess_table_name'], then DO NOT enable global db caching with the $db['default']['cache_on'] variable in the dtaabase.php file, as it appears to ignore any attempts to turn caching on or off in the controller, I think it decides to override everything and cache all queries. Instead, turn the global db caching off (set db['default']['cache_on'] to FALSE), and manually determine which queries should be cached or not. In my case, and this should apply to anybody, I don't want any session table queries cached, so I use this type of code when I save the userdata.... Code: $this->db->cache_off(); I also make sure to turn caching on at the top of each controller I want to use it. Code: $this->db->cache_on(); Then problem I was witnessing is that if the global db cache is turned on, it'll cache the session SELECT queries anyway, whether you want them to or not. |
Welcome Guest, Not a member yet? Register Sign In |