https://www.icyphoenix.com/viewtopic.php?f=17&t=9374 ----------------------------------- mort Mon 29 Dec, 2014 00:53 What To Cache Or Not? ----------------------------------- Fella's, when a user logs in I cache what I think is required for the session time? But I also leave things out because I'm unsure if they should be in there anyway? :( This is the Dump of the table and I suppose the question is somewhat cryptic, unless I just about explain every column - But any suggestion will give me a better idea? The XX's are obviously left out. :mricy: What would [i]YOU[/i] leave out? I mean would you add the AIM, YIM and 'other' link info along with occupation and interest's ? :oops: [spoiler][code linenumbers=false]CREATE TABLE IF NOT EXISTS `users_table` ( `userid` int(11) NOT NULL, `username` varchar(50) NOT NULL, XX `password` varchar(60) NOT NULL, XX `email` varchar(100) NOT NULL, `user_level` tinyint(11) NOT NULL DEFAULT '1', `plays` int(11) NOT NULL DEFAULT '0', XX `newsletter` tinyint(1) NOT NULL DEFAULT '0', `aim` varchar(150) NOT NULL, `icq` varchar(150) NOT NULL, `msn` varchar(150) NOT NULL, `yim` varchar(150) NOT NULL, `location` varchar(150) NOT NULL, `occupation` varchar(50) NOT NULL, `website` varchar(150) NOT NULL, `link_a` varchar(150) NOT NULL, `link_b` varchar(150) NOT NULL, `link_c` varchar(150) NOT NULL, `link_d` varchar(150) NOT NULL, `link_e` varchar(150) NOT NULL, `link_f` varchar(150) NOT NULL, `link_g` varchar(150) NOT NULL, `link_h` varchar(150) NOT NULL, `sex` tinyint(1) NOT NULL DEFAULT '0', `interests` varchar(255) NOT NULL, `bio` text NOT NULL, `ip` varchar(50) NOT NULL, `blog_level` tinyint(1) NOT NULL DEFAULT '1', `game_level` tinyint(1) NOT NULL DEFAULT '1', `avatar` tinyint(1) NOT NULL DEFAULT '0', `avatar_file` varchar(50) NOT NULL, XX `activation_key` varchar(50) NOT NULL, `status` varchar(50) NOT NULL, XX `pass_answer` varchar(255) NOT NULL, XX `pass_question` varchar(255) NOT NULL, XX `new_email` varchar(255) NOT NULL, XX `new_email_key` varchar(255) NOT NULL, `date_joined` varchar(50) NOT NULL DEFAULT '', `user_style` varchar(60) DEFAULT 'default', `user_lang` varchar(50) DEFAULT NULL, `user_session_time` int(11) NOT NULL DEFAULT '1355396812', `user_flag` varchar(50) DEFAULT NULL, XX `xmas_snow` int(15) NOT NULL DEFAULT '0' ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;[/code][/spoiler] ----------------------------------- Informpro Tue 30 Dec, 2014 03:07 Re: What To Cache Or Not? ----------------------------------- Hey. First off - I don't think you need AIM and YIM fields anymore... Let alone MSN. We're in 2014! I'd just query everything at once, and cache it. You don't pay much for one column, if you're only fetching one record. Just try to remember that, when the user updates one of them – or if a field can be changed by some admin at some point, you need to clear the cache. ----------------------------------- mort Tue 30 Dec, 2014 05:36 Re: What To Cache Or Not? ----------------------------------- Thanks my friend. ;) Yeah I suppose Yim, MSN, and the rest of the IM's have bit the dust! along with the manual telephones? :lol: So what replaces it - Skype? As for the cache, I've just about finished converting my toy from MySQl to PDO and am going to replace the caching script with something better - So I'll read up on the new script to see if it can be sectionalised to not cache everything or if it can be "refreshed or cleared" as required by Submit etc. A bit of reading and testing to do... ----------------------------------- Informpro Tue 30 Dec, 2014 14:33 Re: What To Cache Or Not? ----------------------------------- I guess skype, maybe twitter/facebook field. ----------------------------------- Mighty Gorgon Sat 10 Jan, 2015 09:08 Re: What To Cache Or Not? ----------------------------------- [b]mort[/b], you are becoming a cache maniac. :mricy: ----------------------------------- mort Sun 11 Jan, 2015 07:33 Re: What To Cache Or Not? ----------------------------------- And I'm being driven to complete bloody despair over something else I'm trying to do and I can't see the forest for the trees :x Do you know how to create a workable checkbox array to delete selected items from the Db? Because I can't seem to throw enough arguments into the DELETE FROM - WHERE so that it doesn't delete every box that's NOT checked... ? :twisted: They'll delete one by one if the column is set to 1 but when I deactivate with another checkbox array/script and set the column as 0 where the theme is disabled it will either remove all but one of the deactivated themes? :censored: Here's the script... [spoiler] [b]Mmmmm! I fixed it - Now maybe I can look at the caching...[/b] :lol: :twisted: :mrgreen: [/spoiler] ----------------------------------- mort Fri 30 Jan, 2015 02:02 Re: What To Cache Or Not? ----------------------------------- [quote user="Mighty Gorgon" post="59984"][b]mort[/b], you are becoming a cache maniac. :mricy:[/quote] Mmm, Yeah, Well - I downloaded a few caching classes and tried them out and settled on one called RayCache - And it's pretty good. But! - One can't use it to directly cache the queries - more or less it caches the pages and the queries obviously get added. But I wanted to cache queries on pages that couldn't all be cached - So I went looking for a "PDO" caching class? Guess what I found out! PDO with its 'prepared' statements doesn't need to be cached because the data is always available and can be called multiple times without having to make multiple requests.. No wonder I noticed a speed difference once I switched fully to PDO? :P So when is IP going to start using it? :twisted: ----------------------------------- Informpro Fri 30 Jan, 2015 16:34 Re: What To Cache Or Not? ----------------------------------- [quote]Guess what I found out! PDO with its 'prepared' statements doesn't need to be cached because the data is always available and can be called multiple times without having to make multiple requests.. [/quote]No, that's wrong (and doesn't make sense to start with). Only the queries are cached. ----------------------------------- mort Fri 30 Jan, 2015 22:01 Re: What To Cache Or Not? ----------------------------------- [quote user="Informpro" post="60003"]Only the queries are cached.[/quote] I think I said that? :mrgreen: "But I wanted to cache queries on pages that couldn't all be cached." Maybe I should have said, [i]But I wanted to cache only the queries on pages that couldn't be cached to add the html also? Because PDO caches the queries anyway.[/i] ;) ----------------------------------- Informpro Sat 31 Jan, 2015 22:58 Re: What To Cache Or Not? ----------------------------------- Alright, I'll rephrase: only the query *generation* (as in SQL string) *can* be cached. The querying and the results *aren't* cached (unless you do it). ----------------------------------- mort Sat 31 Jan, 2015 23:20 Re: What To Cache Or Not? ----------------------------------- I do understand what you are saying - Maybe the whole subject is confusing.. :lol: But this is how I ended up doing it anyway. So the page is cached as html - gZipped and not serialized. ;) [spoiler][code linenumbers=false] 'cache/gamedata/', 'prefix' => 'gnu_', 'expire' => $set['cachelife'])); $data = $cache->read(''.$template.'.newest_header'); if ($data) { echo $data; }else{ $cache->start_caching(); $limit_header_block = intval($limit_header_block); $ID = isset($_GET['ID']) ? intval($_GET['ID']) : ''; echo '
'.IMG_THL.'
'.$lang['newest_games'].'
'.IMG_MIN.' onclick="ShowHide(\'c41_f\',\'c41_f_h\',\'c41_f\');" alt="'.$lang['hide'].'" title="'.$lang['hide'].'" /> '.IMG_THR.''.SCRST.'
'; $stmt = $database->prepare("SELECT ID, name, description, type, views, thumb, thumb_url FROM " . GAMES_TABLE . " WHERE active='1' ORDER BY date_added DESC LIMIT $limit_header_block"); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach( $result as $row ){ $row_id = intval($row['ID']); $row_type = intval($row['type']); $row_views = intval($row['views']); $row_thumb = gnuFile($row['thumb']); $row_thumb_url = urldecode($row['thumb_url']); $bodydata = htmlEsc($row['description']); $game_name = htmlEsc($row['name']); include "editor/editor_bodydata.php"; $game_link = ''.U_GAME_LINK.$row_id.''; if($row['type'] == 1){echo ' '; }else{ echo ' '; } if($row['type'] == 1){ echo ''.IMG_THUMB_B1.$row_thumb.IMG_THUMB_45.''; }else{ echo ''.IMG_THUMB_B2.$row_thumb_url.IMG_THUMB_45.''; } echo ''; } echo '
'.SCRSB.''.IMG_THB.'
'; $cache->write(''.$template.'.newest_header'); $cache->stop_caching(); echo $cache->read(''.$template.'.newest_header'); } ?>[/code][/spoiler] And this is what we get - Neat! isn't it? 8) [spoiler][code linenumbers=false]a:2:{s:6:"expire";i:1422699771;s:4:"data";s:15363:"
Newest Games
Hide
";}[/code][/spoiler]