[RC] SQL Cache (Cached Generation)

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Post by Hannibal_King »

Thoul wrote: I ran into a bug with this mod tonight. I'm using mysql4.php, and it seems that the changes to the sql_fetchrowset function do not create the cache correctly. All the rows returned are cached with a value of NULL. Take for example, this code:

Code: Select all

$images = $db->sql_fetchrowset($result);
The cache file created by this is:

Code: Select all

<?php $set = array (
  0 => NULL,
  1 => NULL,
  2 => NULL,
  3 => NULL,
  4 => NULL,

// I cut the rest out, but you get the idea! 19 lines of NULLs.

); ?>
I found two ways to fix this. The first is to rewrite the code to use sql_fetchrow, which works fine. That's not an extremely practical solution for me, as I use sql_fetchrowset in several of my mods and custom codings.

The second fix is to change this part added by the mod to sql_fetchrowset (be careful that you don't change the part in sql_fetchrow!):

Code: Select all

				if($this->caching)
				{
					if($this->row[$query_id] === false)
					{
						$this->write_cache();
					}
					$this->cache[] = $this->row[$query_id];
				}
I changed it to this, and then the cache was created correctly:

Code: Select all

				if($this->caching)
				{
					if($this->rowset[$query_id] === false)
					{
						$this->write_cache();
					}
					$this->cache[] = $this->rowset[$query_id];
				}

is this fix working? because i got still many of this cached files:

Code: Select all

<?php $set = array (  
); ?> 
:(

Thoul
Registered User
Posts: 810
Joined: Sun Jun 23, 2002 1:25 am
Location: USA
Contact:

Post by Thoul »

This fix doesn't deal with that issue. It deals with files that contain a series of lines with NULL entries, like those in the section you quoted.

mridang_agarwal
Registered User
Posts: 79
Joined: Fri May 26, 2006 10:40 am

Post by mridang_agarwal »

This MOD is great apart from a few minor thing. I'm not sure wether I'm missing them or is the MOD missing them. How does the cached data get cleared and refreshed? Does it clear/refresh automatically after a particular number of queries or do u have to manually call the clear_cache function after any update/insert/delete operation?
Mridang Agarwal

User avatar
Ash Hi Fi Zone
Registered User
Posts: 409
Joined: Fri Feb 09, 2007 11:55 am

Post by Ash Hi Fi Zone »

Well it did reduce the no. of queries and also the page generation time significantly when the same page was refreshed.... It is indeed a helpful mod... Thank you :D

Thoul
Registered User
Posts: 810
Joined: Sun Jun 23, 2002 1:25 am
Location: USA
Contact:

Re: [RC] SQL Cache (Cached Generation)

Post by Thoul »

For people getting a lot of files like this:

Code: Select all

<?php $set = array ( 
); ?>
I've come up with a little add-on that will write the query being cached into each cache file. This will allow you to see what queries are generating these files.

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
# If you're using mysql.php, the steps are the same, just apply them to that file
#
db/mysql4.php

#
#-----[ FIND ]------------------------------------------
#

	var $num_queries = 0;

#
#-----[ AFTER, ADD ]------------------------------------------
#

	var $cached_queries = array();

#
#-----[ FIND ]------------------------------------------
#

			return $this->query_result;

#
#-----[ BEFORE, ADD ]------------------------------------------
#

			// Record the query for caching.
			if( $cache )
			{
				$this->cached_queries[$this->caching] = $query;
			}

#
#-----[ FIND ]------------------------------------------
#

		@fputs($f, '<?php $set = ' . $data . '; ?>');

#
#-----[ REPLACE WITH ]------------------------------------------
#

		@fputs($f, '<?php /* Cached query:' . "\n\n");
		@fputs($f, $this->cached_queries[$this->caching]);
		@fputs($f, " */\n\n");
		@fputs($f, '$set = ' . $data . '; ?>');

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
With this add-on installed, your cache files will look like this:

Code: Select all

<?php /* Cached query:

SELECT ban_ip, ban_userid, ban_email 
		FROM bbs_banlist 
		WHERE ban_ip IN ('7f000001', '7f0000ff', '7f00ffff', '7fffffff')
			OR ban_userid = -1 */

$set = array (
); ?>
As you can see in this case, the blank file came from a check on the banlist table when I viewed my forum as a guest. If I wanted, I could now track down this query in sessions.php and disable the caching on it.

User avatar
Ash Hi Fi Zone
Registered User
Posts: 409
Joined: Fri Feb 09, 2007 11:55 am

Re: [RC] SQL Cache (Cached Generation)

Post by Ash Hi Fi Zone »

Thank you for the fetchrowset fix - I too noticed of late such NULL entries and it gets fixed ;-)

Sandman1979
Registered User
Posts: 71
Joined: Mon Oct 10, 2005 9:57 pm

Re: [RC] SQL Cache (Cached Generation)

Post by Sandman1979 »

Gonna try this mod, but how doesit affect the ram on the server?

richey
Registered User
Posts: 616
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

Re: [RC] SQL Cache (Cached Generation)

Post by richey »

HELP!

since I installed this MOD (I'm using ExtremeStyles), my cached directory fills up with thousands of cached SQL files daily, so it kindof 'collects' 10-50,000 SQL files every week if I don't clean it manually, how can I avoid this? :? :?

thanks,...
.

Chaos_Maker
Registered User
Posts: 8
Joined: Mon May 21, 2007 11:10 am

Re: [RC] SQL Cache (Cached Generation)

Post by Chaos_Maker »

Hello There.

I installed this the other day on my site, The sql Thing down the bottom said the site was taking like 7 queries on the index page...

However, When i Install the Extream Styles Mod after that, Page load time was cut down a bit, But, Sql Queries have jumped up to like 27 now... Is This Normal?

Post Reply

Return to “[2.0.x] MODs in Development”