application-wide shared data/object
| From: | Aiguo Fei | Date: | Thu, 28 Jul 2005 00:40:24 +0000 |
| Subject: | application-wide shared data/object | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219461@lists.php.net to get a copy of this message | ||
In ASP.Net there is the concept of "application" which is a virtual
directory on a Web server. An application can have application-wide
shared data/objects, which can be accessed by any script of that
application (i.e., scripts under the virtual directory). I have gone
through several PHP books, haven't seen it mentioned anywhere that PHP
has similar facility. I don't know if anyone has written an extention
to do something similar. Or any experience/suggestion on this matter.
To make it clear, consider the following example. I want to do
web-based dictionary. To achieve good performance, I want to load the
whole dictionary into memory when the "application" starts (e.g., when
the web server starts, or triggered when the first script under a
certain directory is requested), and build a lookup table; then create
a globally-accessible object, let's say, Application["my_dict"]; and
it provides a function to do the dictionary lookup. In a script, one
could do something like:
$definition=Application["my_dict"]->lookup( $word );
For a complete solution, it should support object locking/exclusive
access as well.