Re: [ROOT] [Carrot] Persistant Object in Apache

From: Ashley Cambrell (ash@freaky-namuh.com)
Date: Wed Apr 03 2002 - 16:30:27 MEST


Hi Valeriy,

Valeriy Onuchin wrote:

> Hi Ashley,
>
>Ashley Cambrell wrote:
>
>>Hi Valeriy,
>>
>>Is there any mechanism that's already part of Carrot to cache TObjects
>>across all Apache instances?  For things like persistant (pooled)
>>database connections and the like. (sessions?).
>>
>
>Currently there is no such mechanism. Such mechanism would be based
>on sharing objects in TMapFile. However I failed to use libNew and
>TMapFiles with Carrot ( I'll look at this problem again).
>
Create maybe a TCachedObject class that would use a special form of new 
/ delete that would use TMapFiles?

>
>Another solution would be using TFile with file-locking or with semaphores.
>As a starting point would be implementaion of lock ing Carrot serever-side caching.
>Can found at Carrot_Dir/module/TApacheCache.cxx
>
I don't quite understand what TApacheCache is used for.  There doesn't 
seem to be anyway of putting objects in the cache.. [?]

>
>>I have gone through the source and I can't seemed to find anything that
>>looks like it.  The only thing that look like it could be the same
>>object across all backend is the global gApacheBrowser.  (Is
>>gApacheBrowser the same object under all backends?)
>>
>
>Not. All global instances (like gDirectory, gROOT, gApacheBrowser etc)
>are not shared and are different for each apache subprocesses
>
Aaah ok..

>
>>If there isn't already a mechanism in place, [is it possible and] would
>>there be any argument against adding a TMap like caching object that
>>scripts could store TObjects in? (key being perhaps "sessionid" like
>>PHP, and the value being another TMap like object to store client
>>specific session data)
>>
>
>There is shared memory module for apache
>http://www.engelschall.com/sw/mm/
>probably using of this module along with redefining new/delete operators
>would make it possible. Need to be investigated.
>
Looking at the php source, the session handler they use is extremely 
complex.  Basically it seems to boil down to serializing registered 
variables to a single char*which is saved in the an mm segment.  Once 
session_start has been called (can be implied by sessions_register or 
accessing $_SESSION) the data is unserialized and placed into $_SESSIONS 
or if register_globals is on, then the appropriate variable is created.

Is there a file that is run everytime a new connection to Apache is made 
(new connection that calls a Carrot file).  It says that 
CarrotChildInit.C and CarrotChildExit.C are called when the server 
spawns a new server.  But Apache is usually configured so that

StartServers 100
MinSpareServers 100
MaxSpareServers 200

does this mean that if the site is a low traffic site, CarrotChildInit.C 
and CarrotChildExit.C would rarely get called as there would rarely be a 
server startup?  (Or does "spawn a new server" mean "a client connection")

If it does mean spawn a new server, is there a way to run functions on 
script startup?

>
>Regards.    Valeriy
>
>
>

Thanks Valeriy

Ashley Cambrell



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET