CodeIgniter Forums
Locking a config variable - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Locking a config variable (/showthread.php?tid=62209)



Locking a config variable - amit - 06-19-2015

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


RE: Locking a config variable - gadelat - 06-19-2015

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.


RE: Locking a config variable - amit - 06-19-2015

(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?