• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Locking a config variable

#1
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).
Reply

#2
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.
Reply

#3
(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?  
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.