You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 56 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Caching or SESSIONS ? [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
clam729
Sergeant
Sergeant


Joined: Aug 18, 2003
Posts: 82


PostPosted: Sat Jul 03, 2004 7:34 pm Reply with quoteBack to top

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";

if ((isset($_SESSION["bm"])) and (isset($_SESSION["bm_num_rows"])))
{
   $bm = $_SESSION["bm"];
   $bm_num_rows = $_SESSION["bm_num_rows"];
} else {
   $tb_array = table_array(&$sql_string);
   $bm = $tb_array["arr"];
   $bm_num_rows = $tb_array["rows"];
   $_SESSION["bm"] = $bm;
   $_SESSION["bm_num_rows"] = $bm_num_rows;
}


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 Wink

Ideas ?
Thanks.
Find all posts by clam729View user's profileSend private message
djmaze
Captain
Captain


Joined: Nov 29, 2003
Posts: 566

Location: Netherlands

PostPosted: Sun Jul 11, 2004 8:31 am Reply with quoteBack to top

Use both

_________________
Famous people never give their signature Rolling Eyes
http://www.cpgnuke.com <- back online thanks to dedicatednow.com
Don't ask me to be admin on your site please Exclamation
Find all posts by djmazeView user's profileSend private messageVisit poster's website
steven111
Lieutenant
Lieutenant


Joined: Dec 30, 2003
Posts: 283


PostPosted: Mon Oct 04, 2004 9:26 pm Reply with quoteBack to top

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.

_________________
ezClassifieds|Forums:Auto,Mac,Job,Win,HW
Find all posts by steven111View user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
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



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.407 Seconds - 421 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::