Jump to content

link and color username


doddsey_65

Recommended Posts

i need to color the username of user to display which group they belong to on my forum. i do this by running a query which gets their group and joins the group table to get the color. I then return the link which is colored accordingly. However this means a query for every username that is displayed on the screen. I did this the same way on the old version of the forum and it seemed fine. My query count would stay at around 14 regardless of how many users were on screen. However in this new version i am getting around 25 queries because of this, most of them getting the color for every user. is there a better way to do this?

Link to comment
https://forums.phpfreaks.com/topic/238886-link-and-color-username/
Share on other sites

Well you're going to have to query for those 25 users eventually. Maybe you should try some simple caching for 5 or 10 minutes. I'm sure that the user list doesn't have to be completely accurate all the time, does it?

 

You could do a simple file cache where you generate the HTML needed to display the user list and then save that in a file. Let's say you have something like 15 requests per second, if you do those 25 queries for each request then over the course of 10 minutes you've performed 15,000 queries. However if you queried the information and stored it in a cache for 10 minutes then you are down to 25 queries per 10 minutes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.