Jump to content

Recommended Posts

I am making a PHP based game. For my item generation system, I have the base stats for each item TYPE defined and I want to know where I should store them. Since these are type definitions and not the generated items themselves, this data does not change unless I manually do it. For example, the oversimplified data might look like this:

Item name - Min Attack - Max attack

Knife - 3 - 5

Dagger - 5 - 7

 

And so on. When the item generation script is run, it loads this data and generates an attack range in between those values. What my problem is is I'm wondering how to store this data? My first instinct is to store it in the database, but then I would have to query it every time I generate an item, even though the data in there is NOT changing. I know that the database is normally the most overloaded thing on a php based game server, so I would rather not give it unnecessary load. What about XML files? Is the access speed decent enough? My optimal option would be to store it in a database, and have PHP store it in memory. Kind of like sessions, but for the entire server. This way, I get the ease of a database but I don't have to waste time requerying unchanging data. Is that even possible?

Link to comment
https://forums.phpfreaks.com/topic/133546-best-data-storage-solution/
Share on other sites

If you are afraid of the database being overloaded than xml should be fine, easy to manipulate/add to if necessary and easy to read. But I think that once the user has a connection to the database it will not matter running an extra 1 or 2 queries.

 

Thats my opinion anyway. I think the database is the way to go.

And that's the purpose of the DB...

Ok true, but querying the database puts unnecessary load on the database server. Since this is normally the bottleneck of a web based application, I'd like to avoid it if possible.

 

Would this be a solution? http://us3.php.net/manual/en/book.memcache.php

Ok true, but querying the database puts unnecessary load on the database server. Since this is normally the bottleneck of a web based application, I'd like to avoid it if possible.

 

Would this be a solution? http://us3.php.net/manual/en/book.memcache.php

I can't really believe that this game is putting such an overhead on the database server that it can't handle one more query.

 

However, if you are seriously concerned about this, APC might be better than memcache.

You need to install a memcached server for memcache, while APC is a simple installation that works within the web server, and it is faster than memcache.

Ok true, but querying the database puts unnecessary load on the database server. Since this is normally the bottleneck of a web based application, I'd like to avoid it if possible.

 

Would this be a solution? http://us3.php.net/manual/en/book.memcache.php

I can't really believe that this game is putting such an overhead on the database server that it can't handle one more query.

 

However, if you are seriously concerned about this, APC might be better than memcache.

You need to install a memcached server for memcache, while APC is a simple installation that works within the web server, and it is faster than memcache.

 

Hmm, thanks that looks like what I'm looking for. And I haven't even really started programming the core of the game yet, I am just planning ahead. You're right, one query probably won't do much, but this item generation script isn't the only script were persistence would be helpful.

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.