Log in

View Full Version : Cached Information


Logikos
01-30-2006, 08:25 PM
I was wondering how exacly is the process proformed to cache data. Like here on vBulletin.org. The forum poral seems to be cached information retrived from the database every 10mins?

I was wondering how I can do something simalar to this. Like if I wanted to get the latest 10 threads posted on my forum I could run a SQL query and it gives me the infomation everytime the page is refreshed.

example:

$gettitles = $db->query_read("
SELECT title
FROM " . TABLE_PREFIX . "thread
WHERE forumid = 1
ORDER BY dateline
LIMIT 5
");


while ($thread = $db->fetch_array($gettitles))
{
echo $thread['title'];
}


That will get the latest 5 thread titles in forum id 5. How can I cache something like that? Thanks guys! :)

Princeton
01-30-2006, 09:05 PM
save it into datastore and and check timestamp
if (timestamp < TIMENOW)
{
DO QUERY;
}
else
{
use datastore info
}

another option is saving data into files (file name = md5(title+timestamp))

Logikos
01-31-2006, 12:14 AM
Thanks princeton, I see how its done now :)

Princeton
01-31-2006, 12:34 AM
no problem ... I have a similar system.
make sure you place some checks when editing/deleting a thread/post ... eg. update datastore information

Logikos
01-31-2006, 12:38 AM
Yea, I need to get on the ball with learning the datastore system vBulletin has been using. I get lazy :p