Answer the question
In order to leave comments, you need to log in
Where to store data that changes every 3-6 months?
Hello everyone, there is data that is updated in a maximum of 3-6 months, and may not change for a whole year, for example, the names of data types
$types = [1 => 'Автомобили', 2 => 'Недвижимость', 3 => 'Путешествия'];
Answer the question
In order to leave comments, you need to log in
Store them in the database, but cache them at the same time. In order not to run to the database every time for such a dictionary.
If the data changes so "frequently", then why not put it in a separate PHP dictionary - just a file that contains an array and is included where it is needed.
Minus - yes, it will be necessary to climb and change hands every time, but once a quarter, I think you can.
You can store in the database, and when you change, export the array to php.
Here is a list of storage methods, in descending order of speed. Serialized arrays are the fastest, but php arrays can be cached by op cache.
Serialized arrays
Plain PHP code
INI files
XML files
YAML files
Umm, well, obviously not in the radish. It must store data in RAM, and relational databases - on disk. Who in the end is more suitable for storing data that rarely changes?
It is in mysql that you store it. Especially since there are no restrictions. Why do you "don't want" to store them there?
I suggest storing this data in the database as well, but caching its output directly in PHP. For example, with each data change or by cron (for example, once a day), run a script that will select from the database and regenerate the types_data.inc.php file or as a serialized array.
Thus, you will solve the problem of list administration (sorting, filtering, adding a new one, changing, renaming) once every 3-6 months, and with a daily read request, a request to the database will not be made every time.
Although it's not a fact that a file will be faster - a "hot" database cache may be faster in some situations than reading a file with a file cache full of other files.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question