[svlug] Apache internals: persistence of classes

Ivan Sergio Borgonovo mail at webthatworks.it
Thu Jan 1 07:01:43 PST 2004


Sorry to be enough confused to be unable to find any suitable term to
look in google.

I'd like to write some C++ classes (or C) to be able to write
something like this in my PHP code

- begin c.cpp -
class user {
private:
	int instance;
public:
	int instance() { return ++instance; }
	bool dosomestuff(string formfield) {
		// do crazy things here
		int a = instance*8/5
		if(a>1) return 0;
		else return 1;
};
- end c.cpp -


- begin index.php -
<?
#modulo UID

$user_i = new user

#some code here

?>
- end index.php -

- begin 2.php -
<?
$i = user_i.instance()

if $i>1 then #more than 1 web browser window opened...

if user_i.dosomestuff() then #you're crazy
else #I'm crazy

?>
- end 2.php -

Classes should be persistent. So I don't want Apache load my classes
(code and data) for each request.

Something like this:
http://search.cpan.org/~jbaker/Apache-Session-1.54/Session.pm
but without the need to serialize, place in a DB, retrieve.

What should I read to know:
a) if it is worth to write/use my proposed system
b) if I'm reinventing the wheel
c) how to write such thing
?

I read Apache modules docs but it seems that Apache memory management
will destroy allocated structures as soon as the request has been
satisfied.







More information about the svlug mailing list