Session data in Database Caching |
[eluser]fserrano[/eluser]
Hi all, I'm having trouble understanding Database Caching using CodeIgniter Reactor, Version 2.0.0. As I understand from Database Caching Class in the user guide, the cache is storing database queries. But when opening the files in the cache folder I notice it is also storing session data. This would be fine, except that I read session data to display certain dynamic elements in the view, such as a personalized header. For instance, I display a "Login here" link if the user is not logged in or a "Hello [USERNAME]" if they are. In my tests, after I logged in, the header does not reflect the logged in change, I presume because CI is reading the session data from the cache? Is this what's going on? The behavior only happens when cache is on. Everything works fine if I turn cache off in config/database.php, ie, $db['default']['cache_on']=FALSE; Questions to understand Database Caching better: 1) Is there a difference between Caching (Caching Class) and Database Caching (known as Query Caching in the Database Class)? Shouldn't the former cache the output view page but the latter cache only DB queries? 2) In this topic the user concludes that session queries are also cached if database caching is turned on. His solution is to "manually turn on caching for the queries that will benefit from it". This is from 2008, is this solution still relevant today? 3) Is cache fragmentation the only way to go when displaying dynamic data in views? |
Welcome Guest, Not a member yet? Register Sign In |