NYCPHP Meetup

NYPHP.org

[nycphp-talk] using shared memory

Hans Zaunere zaunere at yahoo.com
Wed Jul 17 14:11:43 EDT 2002


--- Jerry Kapron <jkapron at NewAgeWeb.com> wrote:
> Well, I do not have any code yet, but I can explain what I'm trying
> to do.
> I want to load the most accessed (read from) db tables as arrays into
> a
> shared memory segment at startup. Has anyone done or heard of
> anything like
> that done?

As Ophir said, PEAR has a caching system, which uses shm:

http://www.onlamp.com/pub/a/php/2001/10/11/pearcache.html

And a lot of good stuff here:

http://www.php-accelerator.co.uk/

I'm sure a thorough search on http://sourceforge.net or
http://phpclasses.websapp.com would come up with some sample code as
well.  Also note that some software may be for caching pages already
created and some for caching DB results, but the shm mechanism should
be similar.

> I'm not talking about heap tables but using php's shared
> memory
> functions (shm_*) instead.  I realize that querying those arrays will
> not
> be as easy as quering a sql database but i'll come up with some kind
> of
> interface function(s).

Consider that you may eat more CPU/memory/time walking through an array
than making a well formed query on an optimized table, especially if
we're talking two seperate machines.

>  I should probably mention I'm talking about a
> *very*  busy site with thousands of select queries/sec. Also, I heard
> that
> it's a good idea to rebuild the shm segment often (cron job) due to
> memory
> leaks in PHP when using shm_* functions. Was that ever fixed?

Best bet is bugs.php.net for the status on that.

HZ


> 
> 
> Hans Zaunere wrote:
> 
> > --- Jerry Kapron <jkapron at NewAgeWeb.com> wrote:
> > > any tips or disadvantages of using shm_* functions?
> >
> > I was going to say they are still experimental, but I just looked
> at
> > the manual and apparently they're not anymore :) (I would obviously
> use
> > the latest stable (or even CVS) PHP version).
> >
> > If possible, I'd like to see some of your code, once completed, as
> this
> > is always an interesting topic.
> >
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com



More information about the talk mailing list