James Logan
James Logan

Reputation: 831

What php function to use to pull data from MySQL periodically and display it on website?

I'm running a server and website for an online game.

I need to pull information from the mySQL database containing player names and messages and display it on our website.

I managed to do that with a php script which directly pulls the info from the MySQL database whenever someone opens the page.

However, this puts unnecessary load on the server.

I need to achieve so that the function pulls the data only at certain intervals, for example, every hour.

I have no idea how to do this and what to even look for in terms of functions.

Could anyone show me the right direction?

Upvotes: 1

Views: 193

Answers (1)

duellsy
duellsy

Reputation: 8577

If you're worried about the load being placed on the call being made every time the user opens up the site, perhaps first you should look into caching. Something like APC or memcached, that way there isn't an actual DB lookup, it just returns the same data that it grabbed last time You just set the period that you want the cache to hold the data so that in time it will grab a fresh copy, in your case this would be an hour.

There's a bunch of questions on APC, memcached etc on stack overflow that should be able to help you out, e.g., The best way of PHP Caching

Upvotes: 1

Related Questions