473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

sharing information across requests

Hi

I needed to share some configuration information across requests.
The most straightforward way would be code it in a php file and include it
in every other script.
The problem with this approach is, the configuration script is executed on
every request.
The configuration data once figured out by the script remains the same for a
host, but the script to figure out the data could be arbitrarily complex.
The only mechanism I have figured out so far is to use the
shm_attach ,shm_get_var etc functions to store a single php array with all
my config in sysv shared memory.
So, the code to figure out the config runs only once and then populates the
shared mem, after that in every request, the config is read from the shared
memory.

Is this the only way to do this stuff (the main reason for my posting here)
?
Essentially I am looking for something like a static member data in java
which would stay up as long as the class is loaded (which would be across
arbitrary number of requests). For example any java servlet class. The php
static stuff goes away after each request.
I was hoping that stuffing things into $_SERVER would retain things across
requests. No such luck.

Is there a better solution than the SysV shared mem api.
-Antony

P.S. I am using 4.3.4 apache 2.x and 1.x on linux (Fedora Core 3)
Jul 17 '05 #1
3 1790
Can you serialize the configuration data into a database or text file?

- Kevin

"Antony Sequeira" <us***********@hotmail.com> wrote in message
news:Mf****************@newssvr14.news.prodigy.com ...
Hi

I needed to share some configuration information across requests.
The most straightforward way would be code it in a php file and include it
in every other script.
The problem with this approach is, the configuration script is executed on
every request.
The configuration data once figured out by the script remains the same for
a host, but the script to figure out the data could be arbitrarily
complex.
The only mechanism I have figured out so far is to use the
shm_attach ,shm_get_var etc functions to store a single php array with all
my config in sysv shared memory.
So, the code to figure out the config runs only once and then populates
the shared mem, after that in every request, the config is read from the
shared memory.

Is this the only way to do this stuff (the main reason for my posting
here) ?
Essentially I am looking for something like a static member data in java
which would stay up as long as the class is loaded (which would be across
arbitrary number of requests). For example any java servlet class. The php
static stuff goes away after each request.
I was hoping that stuffing things into $_SERVER would retain things across
requests. No such luck.

Is there a better solution than the SysV shared mem api.
-Antony

P.S. I am using 4.3.4 apache 2.x and 1.x on linux (Fedora Core 3)

Jul 17 '05 #2
Antony Sequeira wrote:
Hi

I needed to share some configuration information across requests.
The most straightforward way would be code it in a php file and include it
in every other script.
The problem with this approach is, the configuration script is executed on
every request.
That is what I do. I resigned myself to the fact that in a stateless web
application every request basically restarts the whole application all
over again (apart from possible persistent $_SESSION variables).

A few years ago I attended a talk about persistent PHP objects (it was
called "PHP Bananas", very clever, supposed to be the PHP version of
"Java Beans" if I understood things correctly), something that could
help to get more 'state' in web apps, but I don't know if that project
is still active or how far they got.
The only mechanism I have figured out so far is to use the
shm_attach ,shm_get_var etc functions to store a single php array with all
my config in sysv shared memory.


I'm not familiar with those functions. Wouldn't a session also work in
your case (since you are only storing an array)?

JP
--
Sorry, <de*****@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Jul 17 '05 #3
.oO(Antony Sequeira)
Essentially I am looking for something like a static member data in java
which would stay up as long as the class is loaded (which would be across
arbitrary number of requests). For example any java servlet class. The php
static stuff goes away after each request.
I was hoping that stuffing things into $_SERVER would retain things across
requests. No such luck.


This question was asked few weeks ago. See this thread for some answers:

where do you store app wide data?
http://groups.google.com/groups?thre...1.iinet.net.au

Micha
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vic | last post by:
Hi, Is there a mechanism within PHP for sharing data over multiple requests that are not tied to a specific session. I need to write a memory senstive cache in pure PHP. I have an application...
0
by: Magic1812 | last post by:
Magic Software invites you to join us this coming Tuesday (January 13th, 2004) at 12:00 EDT / 17:00 GMT for a FREE live Webinar: Title: Accelerated Application Integration and Information...
0
by: Magic1812 | last post by:
Magic Software invites you to join us this coming Tuesday (January 13th, 2004) at 12:00 EDT / 17:00 GMT for a FREE live Webinar: Title: Accelerated Application Integration and Information...
10
by: Suresh | last post by:
how to share Session Sharing Across the domain
0
by: Daniel Malcolm | last post by:
Hi I have a site where I would like some pages to be accessed via SSL (login and payment etc) and others via regular http. However I'm not sure whether Session state can be maintained between...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
0
by: voipdealer | last post by:
I have to interface to a third-party application that receives HTTP POSTs with XML content to a certain port on the server. The server is *not* a web server, rather some custom server app written...
7
by: Nils Hedström | last post by:
I have a web farm that uses a state server for session management. A user logs on to a website (www1.mysite.com). When the same user visits www2.mysite.com I want the user to be logged in. Right...
4
by: 6kjfsyg02 | last post by:
I am trying to keep some cached information across several SoapExtensions: In my project there are client applications (web and console) that ask a web service. The web service is also mine. But...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.