How do I reduce number of redundant requests with mod_perl properly?
- by rassie
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:
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
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)
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?