[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mason
Subject:    Re: [Mason] Large data structure in Mason
From:       "P. Fleury" <fleury () users ! sourceforge ! net>
Date:       2007-08-08 16:03:39
Message-ID: f473c7de0708080903q6b259db9mde3e9b75307b95bc () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Lisa,
As it looks you are doing translations, have you considered using something
like Locale::Maketext ? Your substitution texts would then be in a
particular Perl package. Not sure about the speed of mapping, but the
package is very mature, so my guess is that it will be a small hit.

--pascal

On 8/7/07, Lisa Klein <lisaklein20@gmail.com> wrote:
>
> Hi All,
>
> I'm developing a Mason web application that needs to perform a large
> amount of variable substitution.  (e.g. 'hello' -> 'bonjour', 'bye' -> 'au
> revoir', etc...)  There are about 3,000 key/value pairs associated like
> this.  About 25% of all components perform a good amount (50+) of these
> types of substitutions, so the replacements need to happen quickly.
>
> Since it seems unwise to use a database to perform so many operations so
> frequently, I'm leaning towards using a predefined hash. e.g.:
>   my %translate = ('hello' => 'bonjour', 'bye' => 'au revoir', ..... 3,000
> more key/value pairs ...);
>   $var = $translate{$var};
>
> What would be the advisable method of defining such a hash in a Mason
> environment?  Currently I'm considering:
>
> 1. loading a global %translate in handler.pl, making it available to all
> components
> 2. defining %translate in the <%once> section of components that perform
> substitution
> 3. storing %translate in a mason cache, and retrieving it in components
> that perform substitution
>
> The global hash defined in the handler.pl would make my life easiest, but
> I'm concerned that I don't fully understand the implications (if any) of
> defining such a large global data structure in this way.
>
> I'm definitely open to any other suggestions as well.  Thanks in advance!
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users
>
>

[Attachment #5 (text/html)]

Hi Lisa,<br>As it looks you are doing translations, have you considered using \
something like Locale::Maketext ? Your substitution texts would then be in a \
particular Perl package. Not sure about the speed of mapping, but the package is very \
mature, so my guess is that it will be a small hit. \
<br><br>--pascal<br><br><div><span class="gmail_quote">On 8/7/07, <b \
class="gmail_sendername">Lisa Klein</b> &lt;<a href="mailto:lisaklein20@gmail.com" \
target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> \
lisaklein20@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> Hi All,<br><br>I&#39;m developing a Mason web application that \
needs to perform a large amount of variable substitution.&nbsp; (e.g. &#39;hello&#39; \
-&gt; &#39;bonjour&#39;, &#39;bye&#39; -&gt; &#39;au revoir&#39;, etc...)&nbsp; There \
are about 3,000 key/value pairs associated like this.&nbsp; About 25% of all \
components perform a good amount (50+) of these types of substitutions, so the \
replacements need to happen quickly. <br><br>Since it seems unwise to use a database \
to perform so many operations so frequently, I&#39;m leaning towards using a \
predefined hash. e.g.:<br>&nbsp; my %translate = (&#39;hello&#39; =&gt; \
&#39;bonjour&#39;, &#39;bye&#39; =&gt; &#39;au revoir&#39;, ..... 3,000 more \
key/value pairs ...); <br>&nbsp; $var = $translate{$var};<br><br>What would be the \
advisable method of defining such a hash in a Mason environment?&nbsp; Currently \
I&#39;m considering:<br><br>1. loading a global %translate in handler.pl, making it \
available to all components <br>2. defining %translate in the &lt;%once&gt; section \
of components that perform substitution<br>3. storing %translate in a mason cache, \
and retrieving it in components that perform substitution<br><br>The global hash \
defined in the  handler.pl would make my life easiest, but I&#39;m concerned that I \
don&#39;t fully understand the implications (if any) of defining such a large global \
data structure in this way.<br><br>I&#39;m definitely open to any other suggestions \
as well.&nbsp; Thanks in advance! <br>
<br>-------------------------------------------------------------------------<br>This \
SF.net email is sponsored by: Splunk Inc.<br>Still grepping through log files to find \
problems? &nbsp;Stop.<br>Now Search log events and configuration files using AJAX and \
a browser. <br>Download your FREE copy of Splunk now &gt;&gt; &nbsp;<a \
href="http://get.splunk.com/" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">http://get.splunk.com/</a><br>_______________________________________________
 <br>Mason-users mailing list<br><a href="mailto:Mason-users@lists.sourceforge.net" \
target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">Mason-users@lists.sourceforge.net</a><br><a \
href="https://lists.sourceforge.net/lists/listinfo/mason-users" target="_blank" \
onclick="return top.js.OpenExtLink(window,event,this)">

https://lists.sourceforge.net/lists/listinfo/mason-users</a><br><br></blockquote></div><br>




-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic