Hi,

I have a situation where I'd like to store some data in shared memory as
opposed to repetitive database requests. Basically, I'd read in a
(small) database table and serialize the results into shared mem. I've
read through the semaphore and shared memory documentation, but some
things are left unclear.

1) which is better to use, the shm_* sem_*, or the shmop functions? It
looks like shmop may be easier to use and more efficient.

2) How do I test if a shared memory segment exists, and create one if it
doesn't? Here's a bit of psuedo code I'd like to emulate:

        if ( shared mem exists ) {
                open shared mem
                read data from shared mem
                close shared mem
                unserialize data
        }
        else {
                do sql query
                serialize data
                open new shared mem (size of serialized data?)
                write data
                close shared mem
        }
        

3) What size should the opened shared mem size be? shm_* mentions that
the values are serialized implicitly. Does shmop do this, or does this
need to be serialized first in the PHP code?

4) How do I know what to use for the system id for the memory segment?
What is a "safe" value to use? Is there a valid range? Are there some
ranges I should stay away from?

5) Is there a way to tell the age of a shared memory segment, or must I
do this within the data that is stored?

6) Are there any good examples of usage out there? The one that comes
with shmop doesn't show a way to test if the shared memory segment
exists before trying to create a new one (and how do I open an existing
shared mem segment, not necessarily knowing its size?)


I'm using Sparc Solaris 2.8, if that makes a difference.

Thanks!

--
Monte Ohrt <[EMAIL PROTECTED]>
http://www.ispi.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to