All,
I have been doing some benchmarking on MySQLs Query Caching and storing the returned db info in a session var.
For example, a user hits module "apple" - the db is read and the information to be displayed is returned - great.
The user then goes to the "banana" module, same thing, the db is read and the information is displayed.
They now decide to go back to the "apple" module - now, here is where I'm doing my testing. 1) to see if the MySQL cache is faster/more efficient than storing the original returned data in a session var and doing an isset on returned visits (for that session).
Without caching or sessions, the db is constantly being accessed, when it really shouldn't be for modules that don't change (no forums, etc.).
How are others dealing w/this ? Statics ? Sessions ? Caching (either MySQL or MMCache or other) ? Nothing at all ?
I am using something like this:
Code:
session_start();
if ((isset($_SESSION["bmfields"])) and (isset($_SESSION["bmtable"])) and (isset($_SESSION["bmpid"])))
{
$bmfields = $_SESSION["bmfields"];
$bmtable = $_SESSION["bmtable"];
$bmpid = $_SESSION["bmpid"];
} else {
list ($bmfields, $bmtable, $bmpid) = db_bookmarks();
$_SESSION["bmfields"] = $bmfields;
$_SESSION["bmtable"] = $bmtable;
$_SESSION["bmpid"] = $bmpid;
}
$sql_string = "SELECT SQL_CACHE " . $bmfields . " FROM " . $bmtable . " ORDER BY bm_sort";
BTW, my db_bookmarks() and table_array() are not shown, but are called via includes.
Essential, I am trying to determine whether or not I should leave caching by itself, use session variables or a combo of caching and sessions
Ideas ?
Thanks.
djmaze Captain
Joined: Nov 29, 2003
Posts: 566
Location: Netherlands
Posted:
Sun Jul 11, 2004 8:31 am
Use both
_________________ Famous people never give their signature http://www.cpgnuke.com <- back online thanks to dedicatednow.com
Don't ask me to be admin on your site please
steven111 Lieutenant
Joined: Dec 30, 2003
Posts: 283
Posted:
Mon Oct 04, 2004 9:26 pm
Sessions is good if you want per user caching.... i.e. when user goes from one page to another.
Something like mmcache or cachelite is good for site-wide caching, i.e. certain parameter values that need to be carried across all pages regardless of what user is accessing them.
Note that mysql by default has query cache. Used a smart way, this will eliminate a huge number of repeat queries.
static is a way to carry info inside a function from one instance of the function call to another. This is caching on one page only.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum