473,666 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1811
Can you serialize the configuration data into a database or text file?

- Kevin

"Antony Sequeira" <us***********@ hotmail.com> wrote in message
news:Mf******** ********@newssv r14.news.prodig y.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
1606
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 which needs to store documents from an application server elsewhere, due to the data within the documents I can't write them to disk and I have to minimise the amount of accesses to the server.
0
1434
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 Sharing Date: January 13, 2004 Time: 12:00 PM EST / 17:00 GMT Presenter: Lee Sutton
0
1526
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 Sharing Date: January 13, 2004 Time: 12:00 PM EST / 17:00 GMT Presenter: Lee Sutton
10
2208
by: Suresh | last post by:
how to share Session Sharing Across the domain
0
1330
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 the 2 protocols. We have SSL set up on the site so that it can be accessed via the same domain: http://www.mydomain.com/login.aspx
9
5305
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 copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls lose their state because they are effectively different instances of the user control. Is there...
0
1616
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 by the third-party, so it's behavior is not predictable or necessarily HTTP compliant. Therefore, I can't use the much simpler HttpWebRequest. Also, if I repeatedly open new connections to it, the server gets bogged down with authentication and...
7
4394
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 now it he is not logged in on www2.mysite.com (both sites use the same state server). The reason for this seems to be that the user gets a new SessionId when he visits a new web server (www2.mysite.com for example). If there was a way to add a...
4
1289
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 both the client and the server could be different as long as they keep to the message format defined. The information goes through some SoapExtensions in the server and the client to do some processing like signing, schema validation, signature...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6191
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.