Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Caching Log4Perl object and using in various scripts

by chanakya (Friar)
on Sep 14, 2009 at 12:32 UTC ( [id://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

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?

    Martin

      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?
Username:
Password:

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
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 02:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found