CodeIgniter Forums

Full Version: Locking a config variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I'm saving an array in $config array like this one below:
Code:
$config['listed'] = array(86, 52, 265, 7, 580);

And this array get updated from database when a certain event is fired by privileged users. Now my question is that what if a script gets updated values from database & updates the config item and another script tries to read the same config item meanwhile. Should I worry about this and how should I handle the executions?

I know about file locking but never used that and not sure how to apply for a variable (config item).
Changes of config items using config->set_item are only done in memory. It doesn't save changes to config file. So if one script changes config item and meanwhile another script reads the value, second script will not see the changes.
(06-19-2015, 09:43 AM)gadelat Wrote: [ -> ]Changes of config items using config->set_item are only done in memory. It doesn't save changes to config file. So if one script changes config item and meanwhile another script reads the value, second script will not see the changes.

I checked & agree that you are correct. So I need to save them either in file or database and maintain read/write lock or concurrency?