Shared hashtable

php.internals

Stut

20 years ago
Hi all, I'm being asked about the possibility of creating an extension that will cache some data from a MySQL DB in-memory. I've been reading various online resources regarding building extensions and cannot find an answer to the following question... Is there a way to create a hashtable in the extension which will be available to all of the Apache children without resorting to shared memory? It's important that only one instance of the data exists for two reasons... 1) It's a fairly large amount of data and 2) it will change as the application runs. I've created a small test extension using MODULE_GLOBALS the results of which suggest that these variables are per process. I'm just looking for some confirmation that shared memory is the way to go before I jump down that particular black hole. TIA. -Stut

Sara Golemon

20 years ago
> I'm being asked about the possibility of creating an extension that will > cache some data from a MySQL DB in-memory. I've been reading various > online resources regarding building extensions and cannot find an answer > to the following question... Is there a way to create a hashtable in the > extension which will be available to all of the Apache children without > resorting to shared memory? >
You want to *share* something in *memory* between two processes. Yep, ya pretty much need shared memory...
> It's important that only one instance of the data exists for two > reasons... 1) It's a fairly large amount of data and 2) it will change as > the application runs. I've created a small test extension using > MODULE_GLOBALS the results of which suggest that these variables are per > process. I'm just looking for some confirmation that shared memory is the > way to go before I jump down that particular black hole. >
Yes, Module Globals are per-process (or per-thread if your under a threaded sapi). In either case, these are specifically designed to *prevent* concurrent requests from accessing the same data. -Sara