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

Reply via email to