On Tue, Mar 27, 2001 at 05:19:15PM -0500, Pierre Phaneuf wrote:

> DeWitt Clinton wrote:
> 
> > The other question is whether or not to share the cache instance
> > itself globally.  Technically, this is up to you.  Personally I
> > wouldn't bother, considering the overhead of instantiating the
> > cache is so low that I would rather keep it local to the handler
> > (as I did above).  I tend to only share data globally in mod_perl
> > handlers very judiciously, and even then I wrap the data in an
> > object that provides accessor methods.  For an example of an
> > object that wraps shared data, check out Cache::MemoryCache, which
> > simply caches data inside the process.
> 
> Wouldn't this cause the cache to be torn down and rebuilt for every
> request???

The cache instance itself would be, but the data behind it (a global
hash in the case of the MemoryCache, and a IPC::ShareLite store for
the SharedMemoryCache ) would stay around.  Since the instance isn't
that heavy, I feel better instantiating them fresh every request.  If
you need optimal performance, however, you may want to keep the
instance itself global.  

Which reminds me of something.  These cache objects are not currently
thread safe.  When should I start expecting multi-threaded
apache/mod_perl to become mainstream enough to warrant an overhaul of
the code?  I imagine that nearly most Perl libraries are not thread
safe, of course.  But code that will be used in mod_perl environments
needs to be, right?

-DeWitt

Reply via email to