How do I reduce number of redundant requests with mod_perl properly?

Posted by rassie on Stack Overflow See other posts from Stack Overflow or by rassie
Published on 2010-03-08T14:52:50Z Indexed on 2010/03/08 16:36 UTC
Read the original article Hit count: 506

Filed under:
|
|

In a fairly big legacy project, I've refactored several hairy modules into Moose classes. Each of these modules requires database access to (lazy) fetch its attributes. Since those objects are used pretty heavily, I want to reduce the number of redundant requests, for example for unchanged data.

Now, how do I do that properly? I've got several alternatives:

  1. Implement caching in my Moose classes via a role to store them in memcached with expiration of 5-10 minutes (probably not too difficult, but tricky with lazy attributes) update: KiokuDB could probably help here, have to read up about attributes
  2. Migrate to DBIx::Class (needs to be done anyway) and implement caching on this level (DBIC will probably take most of the pain away just by itself)
  3. Somehow make my objects persist inside the mod_perl process (no clue how to do this :()

How would you do this and what do you consider a sane way? Is caching data preferred on object or the ORM level?

© Stack Overflow or respective owner

Related posts about perl

Related posts about caching