Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.