|
Posted by Aiguo Fei on 10/21/24 11:22
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.
[Back to original message]
|