I'm working on a plugin that scans through a website's content, using a dictionary file to match words. Right now when scanning the entire site it schedules a series of functions as events to run immediately so it can run in the background.
Right now each function(There's one for each page content, post content, media files, etc.) is handling loading the dictionary file in but we are trying to find a way to make it so that the file only needs to be loaded into memory once and all the scheduled scan events can use it.
We've tried passing the dictionary file stored in an array as an argument of the function that the event triggers, but it appears to be holding it in the database once for each event and it overloads the server's memory.
I've come across the idea of shared memory extensions in PHP, but we cannot guarantee that we will be able to enable this and would prefer another solution if possible.
Is there any way in WordPress to do this or do we have to load the file into an array once per function?