# Shared hashtable

- Thread: https://externals.io/message/23115
- Original archive: https://news-web.php.net/php.internals/23115
- Started by Stut on 2006-05-03T09:05:44+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #23115 — Stut — 2006-05-03T09:05:44+00:00

URL: https://externals.io/message/23115#23115

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

---

## #23128 — Sara Golemon — 2006-05-03T16:06:43+00:00

URL: https://externals.io/message/23115#23128 · In reply to: #23115

> 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

> TIA.
>
> -Stut
