What is the best way to persist a global array in php?

93 views Asked by At

I need some help about the best way to persist an array of "settings" in php. The application load this settings every time that the page is "refreshed". I can't use databases and store the settings in a file is a bad idea if I need to check every time.

I think that a good solution is store the array (serialized) in a file and then read the file (only one time) and then "freeze" it in "a session"? But I don't know if its secure...

Can you help me?

EDIT:

i did forgot to say that the "settings" change more frecuently because the stored data, save a "cache table" of the rendered page modules. For this reason, i cant use a plain php file to store the settings.

1

There are 1 answers

1
miholeus On

There is no best way. You should choose from your needs. Each method has its own pros/cons. In case of database you will have network costs, but the opportunity to read settings from remote node or service may be beneficial. A file can be cached by php opcode cacher that will boost your app. There is no need to "freeze" it in "a session".