Here is my temp solution to the count clicks issue:
//Getting read-posts data from the session:
$rPosts = $this->Session->read('readPosts');
if(!empty($rPosts))
{
//if the post do not exist in $rposts, add it:
if(!in_array($id, $rPosts))
{
array_push($rPosts, $id);
$this->Session->write('readPosts', $rPosts);
$this->Post->populateCount($id);
//Populate count now adds to a tmp cache file before updating
the
database once every hour.
}
else
{
//do nothing
}
}
//If $rPosts is empty, create a new variable:
else
{
$this->Post->populateCount($id); //Add count to tmp file
$rPosts = array($id);
$this->Session->write('readPosts', $rPosts);
}
Probably not the most efficient way of doing this, but it works and it
does not trouble the database to much.
The populateCount() function now writes clicks to a tmp cache file and
updates the database once every hour.
When getting the clicks it combines the clicks from the database and
the file, with a cache of 5 minutes, so
the database is not overloaded.
Hope this can inspire anyone to make this work even better =)
Bake on!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---