MyBB Community Forums

Full Version: Adding my own Stats to Stats Cache
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I want to add my own stats from my site to the Stats Cache to lower the number of MYSQL queries on my site.

I tried adding
$stats['test'] = "Cheese";
in the updatestats() function in datacache.php, but then when i used print_f to display the stats array, it wasnt there.

Do i need to declare somewhere if i want to add my own stuff to the $stats array?
You're calling $cache->updatestats(); right?

You'll have to refresh the page to see the updated version of the stats cache too - unless you do $stats = $cache->read("stats", 1); which will perform a hard refresh of the array.
Ah thanks Chris, i wasn't calling it lol.

But i just tried adding it, but im using the SDK, and i tried adding an Update Stats function to sdk.php, saying
	function updateStats()
	{
		$this->$cache->updatestats();
	}
but thats probally totally wrong yea? Because i get
Fatal error: Call to a member function on a non-object in /home/mpsounds/public_html/forums/inc/sdk.php on line 216
function updateStats()
{
$this->cache->updatestats();
}
ah yea, i just misread the other function.

Thanks Chris Big Grin Big Grin

btw - are there going to be any more SDK functions in GOLD?
Excuse me, which page do we have to "require" if we want to update our forum stats ?

Is it okay like that :

function updateStats()
{
		$this->update("stats", $stats);
		$this->cache->updatestats();
		$cache->updatestats();
}

Please help Sad
wow this is really really old...

You only need:

$cache->updatestats();

Make sure $cache is declared.
Tikitiki Wrote:wow this is really really old...

You only need:

$cache->updatestats();

Make sure $cache is declared.

Thanks for your answer but, how I can declare $cache ? How can I define it ?

Could you post me page and the line where it's defined ? Is it in class_datacache ? Or something like that ?

Thanks again !
This thing is really important for me...Shy

Bye !
Yes, it's in class_datacache. If you didn't include global.php/init.php you'll need to do something like this:

include "./path/to/forum/inc/class_datacache.php";
$cache = new dataCache();
Tikitiki Wrote:Yes, it's in class_datacache. If you didn't include global.php/init.php you'll need to do something like this:

include "./path/to/forum/inc/class_datacache.php";
$cache = new dataCache();

Hi,

I'm a kind of depressed... I'm not able to fix the problem...
Here's what's in my registration page :

require("config.php");
require("forum/inc/functions_user.php");
require("forum/inc/functions.php");
require("forum/inc/class_datacache.php");
$cache = new dataCache();

function updatestats()
{
		$cache->updateStats();
}

How can I declare $cache if I can't require init.php & global.php ?

Maybe I'm stupid but I really don't see how...Sad
Pages: 1 2 3