V
V
Vitaly Vitaly2015-01-25 15:22:26
PHP
Vitaly Vitaly, 2015-01-25 15:22:26

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 => 'Путешествия'];

Once after some time, when adding a new section of the service, it is possible to add a new type.
This data is accessed frequently, I would not want to store it in MySQL.
The project uses MySQL + Redis.
There is an idea to bring the data into Redis, maybe there is an alternative? Who stores this data where?
Now while development is underway, the data is simply an array in the controller and transferred to the View.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alex Pts, 2015-01-25
@AlexPTS

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.

M
Maxim Kudryavtsev, 2015-01-25
@kumaxim

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.

A
Alexander Gubarev, 2015-01-25
@AlexGx

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

V
Viktor Vsk, 2015-01-25
@viktorvsk

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?

A
Alexey Murz Korepov, 2015-01-30
@Murz

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 question

Ask a Question

731 491 924 answers to any question