Any way to access shared memory from different requests?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Any way to access shared memory from different requests?

Post by the_drizzle »

Given PHP5 and Apache, is there any way to share memory between requests? For example, say one web user accesses a page and something - let's call it Jum - gets placed in memory. If another user accesses a page, or the original user sends a second request, can I access Jum? Your first thought may be to use a database, but let's just assume that a database is too slow for the kind of thing I'm trying to do. If there isn't any way to share memory, then I'll resort to a database.

Thanks for any insight,

Graham
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I don't PHP can do that.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Here's another link to look at also (I guess I may have been wrong)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

have you considered a HEAP table? it would likely have the same-ish performance as what you're after.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

A database would be more portable in most circumstances, however memcache and shmop are the alternatives.

What is the need behind this? Is it actually necessary for the two users to share the page data? Maybe what you're looking for is something a decent caching system and a template engine can handle or sessions.
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Problem Solved

Post by the_drizzle »

Sorry, I should have been more clear. There is a large list of objects that I wish to share between requests to the server for varying reasons. I suppose I could've discussed several examples but I wanted to avoid digression into how to best implement each feature. In theory I should be able to tackle such tasks on my own ;).

I just wanted to investigate all my options before committing myself to a solution. It seems like caching systems are the best way to go. It would be better if I could avoid copying data around so several requests could perform operations on the exact same objects, but I guess PHP doesn't allow for that. Oh well. I think I'll just use a database and put general, intelligent, caching in front of it. Then I'll just set it up so my desired "shared memory" has a high caching priority.

Thanks for your help everyone.
Post Reply