Welcome Guest, Not a member yet? Register   Sign In
Database caching confusion
#1

[eluser]blowmenow[/eluser]
Hi there folks.
Ive got a very serious problem. I cannot see a deferents between those snippets:

Code:
$this->db->cache_on();

and

Code:
$this->db->start_cache();

I'm really confused, are there many types of database caching? Or it is just redundant code? Explain it to me. Thank you!.
#2

[eluser]Otemu[/eluser]
$this->db->cache_on();
Manually enables caching.
http://ellislab.com/codeigniter/user-gui...ching.html

$this->db->start_cache()
This function must be called to begin caching. All Active Record queries of the correct type (see below for supported queries) are stored for later use.
http://ellislab.com/codeigniter/user-gui...ecord.html

#3

[eluser]blowmenow[/eluser]
So where is the different?
Both enable/disable caching. I can't see the point.
With one I suppose to use? It seems pointless.
#4

[eluser]Otemu[/eluser]
Sorry I left a huge chunk out when I copied and pasted before

Active Record Caching

While not "true" caching, Active Record enables you to save (or "cache") certain parts of your queries for reuse at a later point in your script's execution. Normally, when an Active Record call is completed, all stored information is reset for the next call. With caching, you can prevent this reset, and reuse information easily.

Cached calls are cumulative. If you make 2 cached select() calls, and then 2 uncached select() calls, this will result in 4 select() calls. There are three Caching functions available:

I assume then $this->db->cache_on(); is for active records, if both functions work then don't stress about it an just use $this->db->cache_on()
#5

[eluser]blowmenow[/eluser]
Oh, alright, separated cache switch for database with and without active record. This make some sense.

Code:
$this->db->start_cache();
$this->db->stop_cache();
has no effect when active records is ON.

This is very poorly designed.
#6

[eluser]Unknown[/eluser]
start_cache() is queries cache.
cache_on() is result cache.




Theme © iAndrew 2016 - Forum software by © MyBB