Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Caching Log4Perl object and using in various scripts

by chanakya (Friar)
on Sep 14, 2009 at 12:32 UTC ( #795106=perlquestion: print w/replies, xml ) Need Help??

chanakya has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

Currently I am rewriting a bunch of perl scripts to improve performance and used couple of frameworks. One of them is Log::Log4perl

I have 20 perl scripts and one issue I have observed is, everytime a new script executes, a new Log4perl object is created. My idea is to create one Log4perl object and reuse the cached object across all the other scripts to save time in creating new object every time.

To achieve the above I was thinking about:
* Caching the Log4perl object once its created by the first script
* Other scripts use the cached object or it cached object is expired, instantiate the Log4perl object .

I'd like to know what Caching modules will help me achieve this, and also let me know if my approach is correct.

Thank you for your time
  • Comment on Caching Log4Perl object and using in various scripts

Replies are listed 'Best First'.
Re: Caching Log4Perl object and using in various scripts
by marto (Cardinal) on Sep 14, 2009 at 13:12 UTC

    If your goal is to improve performance of some scripts, did you first profile them using something like Devel::NYTProf?


      I second this optimizing before benchmarking is almost always a waste of time.
Re: Caching Log4Perl object and using in various scripts
by Anonymous Monk on Sep 14, 2009 at 12:43 UTC
    what makes you think it is a bottleneck?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://795106]
Approved by planetscape
Front-paged by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2023-01-28 00:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found