How to Cache ?
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #4
RE: How to Cache ?
And what about his?

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
		static $forums_avatar_cache = null;
		if(!isset($forums_avatar_cache))
		{
			global $db, $cache;
			$forums = $cache->read('forums');

			$uidlist = '0';
			foreach($forums as $key => $val)
			{
				$f = $forums[$key];
				if($f['type'] == 'f' && $f['active'] == 1 && $f['lastposteruid'])
				{
					$uidlist .= ','.intval($f['lastposteruid']);
				}
			}

			$query = $db->simple_select('users', 'uid, avatar, avatardimensions', "uid IN ({$uidlist})");
			while($user = $db->fetch_array($query))
			{
				$forums_avatar_cache[$user['uid']] = $user;
			}
		}


It will make one query each page load in index, and forum display (but less code because of $tids and considering it gets the latest thread poster avatar too) is used.

I tried merging my data with the forum cache but it was to many hooks, too many code, and too many troubles to be worth it for such a feature.

Maybe I will ask for a review Smile


Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
05-20-2012 01:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
How to Cache ? - Sama34 - 03-04-2012, 02:55 PM
RE: How to Cache ? - ZiNgA BuRgA - 03-04-2012, 10:55 PM
RE: How to Cache ? - Sama34 - 03-06-2012, 02:33 PM
RE: How to Cache ? - Sama34 - 05-20-2012 01:58 PM
RE: How to Cache ? - ZiNgA BuRgA - 05-20-2012, 03:49 PM
RE: How to Cache ? - leefish - 05-29-2012, 06:08 AM
RE: How to Cache ? - Sama34 - 05-30-2012, 01:43 PM
RE: How to Cache ? - vega - 09-19-2012, 11:52 AM
RE: How to Cache ? - jack3935 - 10-29-2012, 02:25 PM
RE: How to Cache ? - Sama34 - 09-19-2012, 04:29 PM
RE: How to Cache ? - Sama34 - 10-29-2012, 02:48 PM

 Standard Tools
Forum Jump: