In WEB applications, a large amount of static data should be stored in the database or directly stored in the PHP Industry

Source: Internet
Author: User
In WEB applications, should a large amount of static data be stored in the database or directly stored in the PHP service layer? It means that a WEB application with a large amount of static data, such as a WEB game with a MYSQL-PHP-JS architecture, it has a large amount of relatively static data, such as how much experience is required for every upgrade level, for example, parameters of each city and item. This data

In WEB applications, should a large amount of static data be stored in the database or directly stored in the PHP service layer? It means that a WEB application with a large amount of static data, such as a WEB game with a MYSQL-PHP-JS architecture, it has a large amount of relatively static data, such as how much experience is required for every upgrade level, for example, parameters of each city and item. This data

In WEB applications, should a large amount of static data be stored in the database or directly stored in the PHP service layer?
It means that a WEB application with a large amount of static data, such as a WEB game with a MYSQL-PHP-JS architecture, it has a large amount of relatively static data, such as how much experience is required for every upgrade level, for example, parameters of each city and item. These data may only change when the version is updated.

If the data is stored in a database (read-only table), each business needs to query one or more such static data tables.
If it is directly stored in the PHP service layer in the form of an associated array (of course, PHP code automatically generated from the EXCEL planning table architecture ), therefore, defining and operating a large associated array may also affect the efficiency of PHP file execution on the server.

In contrast, which of the above two options is more efficient? It is equivalent to putting pressure on the MYSQL layer or the PHP layer, which is easier.

If you think that I have not made it clear, please reply to the instructions and I will add some instructions.
------ Solution ----------------------
For example, how much experience is required for each upgrade level, for example, parameters for each city and item, etc.
If the upgrade is completed by php code, it doesn't matter what you save.
If the upgrade is completed by the SQL script, you must save it as a table for background implementation.

------ Solution ----------------------
I personally think you are a bit like the system configuration information. If there is a large amount of data, it is recommended to store it in the database and put it in the cache for easy reading.
------ Solution ----------------------
Why do I have to select either of them? Can I use them together?
The data source is stored in mysql, and maintenance is to directly update the data in the database.
Then write a program to cache each group of static data into a php script file, for example, upgrading experience. data. php: 1, 2 => 2 )...
When data is needed, $ upgrade experience = include 'upgrade experience. data. php ';
It is divided into multiple files for storage, which one to read and which to avoid a large number of declarations.
When the data is updated, modify the data in mysql and delete the cache file and run the program again to generate it.

------ Solution ----------------------
I personally feel that they can be stored in databases and redis,

Generally, it is obtained from redis. If redis has no value, it is obtained from mysql.

Set mysql values through php

As long as you maintain the synchronization of mysql and redis (such as my [this article from the Internet (http://www.68idc.cn)] SQL restart to update redis, mysql Updates also update redis)

This is easy to maintain and can be directly stored in the memory. The maintenance and access speed are no problem.

On the second floor, php code is not recommended. This is the worst way... If you really want to, define...

The landlord chooses

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.