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