Thread:Extension talk:Scribunto/Check whether title exists, otherwise load data/reply (5)

I read the documentation for  and for me was obvious that the data module is effectively parsed once and loaded into some internal cache during processing page request. So the best solution shall be: ... local flagsData = mw.loadData("Module:Flags/Data") local flagData = flagsData[requiredFlag] if not flagData then flagData = findFlagIfExistsUsingExpensiveTitleMethod(requiredFlag) if flagData then ... // flags data need to be updated with new available flag data ... // code here may put the article in specific category to notify about it else ... // the flag does not exists ... // code here may put the article in specific category to notify about it   return // optional exit?? end end ... // continue processing with the loaded flag data

The only expensive call is during first #invoke, when the table need to be loaded. For all followed hundreds invokes accessing the data in the same page the  shall return results almost immediately. Please correct me if I am wrong.