if you're needing access to this data from with Mason, you can use Mason's built in data caching. First you create a component file to encapsulate the data you want to share across requests and processes (i.e. "_getSharedData").
# mason component _getSharedData
my $value = $m->cache->get("key");
return $value if(defined($value));
# compute $value here since it hasn't been stored yet
$value = $$;
$m->cache->set(key=>$value);
return $value
Then you can call that component anytime you want to retrieve it.
my $value = $m->comp('/_getSharedData');
Note that Mason's cache, by default, is stored on disk but you can use any Cache::Cache sub-class that you want (Cache::SharedMemoryCache would allow you to share the data across processes without writing it to disk).
$m->cache(cache_class => 'SharedMemoryCache')->set(key=>$value);
$value = $m->cache(cache_class => 'SharedMemoryCache')->get("key");
Also,
$m->cache->get("key") is scoped to the component you are calling it from (so don't expect to be able to access the same data from another component without calling
_getSharedData
For more info on Mason caching, see the
HTML::Mason::Devel docs.
HTH - Brian
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.