<div dir="ltr"><div>I use CHI (<a href="http://search.cpan.org/~jswartz/CHI-0.60/">http://search.cpan.org/~jswartz/CHI-0.60/</a>) for this sort of thing, usually with CHI::Driver::File as this is only for the one server.<br><br></div>- Chris<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 15, 2017 at 1:01 AM, tirveni yadav <span dir="ltr">&lt;<a href="mailto:yadav.tirveni@gmail.com" target="_blank">yadav.tirveni@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Apr 12, 2017 at 4:14 PM, Dr. Jennifer Nussbaum<br>
&lt;<a href="mailto:bg271828@yahoo.com">bg271828@yahoo.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; This may not be strictly Catalyst-related, but I&#39;d be grateful for any help - I dont know much about<br>
&gt; either caching or making things available throughout an app :-(<br>
&gt;<br>
&gt; I have an app that uses a number of different outside configuration files; which one it uses depends on<br>
&gt; several factors, and it will be the same one per request cycle. Parsing each file is an expensive<br>
&gt; calculation. Originally I read it at the beginning of the cycle and passed the resulting variable around,<br>
&gt; but my models are now so complicated that this has gotten tedious, and I wanted to do something<br>
&gt; like have a utility method MyApp::Utilities-&gt;get_outside_<wbr>config($id) that any model can call when it<br>
&gt; needs to. However, I dont want to have to recalculate it in every get_outside_config call.<br>
&gt;<br>
&gt; Whats the best way of handling this? The config is used very often, and could be regarded as global,<br>
&gt; but also most of my models are non-Catalyst ones that are glued in, so $c isnt available to them. The<br>
&gt; config files dont change often.<br>
&gt;<br>
<br>
Caching is a good choice for this problem.<br>
<br>
Store result of your calculations as a hash in a fastmmap/redis.<br>
Do also store the timestamp in the hash.<br>
<br>
Use the hash for all your subsequent request.<br>
And, all of these requests check timestamp for staleness before<br>
deciding to use the hash or go for calculations again.<br>
<br>
Redis Hash operations.<br>
<br>
--<br>
Regards,<br>
<br>
Tirveni Yadav<br>
<a href="http://www.udyansh.org" rel="noreferrer" target="_blank">www.udyansh.org</a><br>
<br>
What is this Universe ? From what it arises ? Into what does it go?<br>
In freedom it arises, In freedom it rests and into freedom it melts away.<br>
Upanishads.<br>
<br>
______________________________<wbr>_________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-<wbr>bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" rel="noreferrer" target="_blank">http://www.mail-archive.com/<wbr>catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/</a><br>
</blockquote></div><br></div>