简体   繁体   中英

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

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.

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM