title: Do I need to call readFileSync() again if I use writeFile() in another js file?
body: <p>I'm making a discord bot, and I currently have it set up like this:</p>
  
  <p>There's index.js, which handles commands.</p>
  
  <p>If the command is X, it goes to X.js</p>
  
  <p>If the command is Y, it goes to Y.js</p>
  
  <p>I have X.js and Y.js both reading and writing to the same JSON file (in non-conflicting areas) using fs.readFileSync() and fs.writeFile()</p>
  
  <p>fs.readFileSync() is only called once in each X and Y at the startup of the command script.
  reading/writing works fine from the same file with that one call, but I haven't testing how it works with multiple scripts writing to the same file with a single call at the beginning.</p>
  
  <p>I assume this isn't going to work? </p>
  
  <p>And, presuming it will not work, what solution would you guys suggest?</p>
  
  <p>Calling fs.readFileSync() in X/Y every time the command X/Y is called (How efficient is this? Right now I don't call commands very often - maybe a couple times an hour at most - but if this ends up going public, there could be quite a few calls of X/Y per second. Would this put a significant strain on the filesystem/bot/etc? I presume not, just making sure!)</p>
  
  <p>Making an outside script to handle reading + writing (X/Y would call on this script for data, and output data to be written.)</p>
  
  <p>Using different files for each script (ahh i really would not like to do this!!)</p>
  
  <p>Maybe another solution? Who knows...</p>
  
  <p>If anyone has done something similar/knows a solution, please don't hesitate to post :)
  Thanks!</p>