in reply to Persistant data with Mason
Then you can call that component anytime you want to retrieve it.# 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
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).my $value = $m->comp('/_getSharedData');
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$m->cache(cache_class => 'SharedMemoryCache')->set(key=>$value); $value = $m->cache(cache_class => 'SharedMemoryCache')->get("key");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Persistant data with Mason
by cowboy (Friar) on Feb 11, 2005 at 21:36 UTC | |
|
Re: Persistant data with Mason
by crenz (Priest) on Feb 12, 2005 at 00:23 UTC |