[Dbix-class] DBIx::Class and caching

Andreas Pronakis andr3as at yahoo.com
Tue Jun 24 15:43:12 BST 2008


Forgive me if this question sounds like asking for baby step instructions  but I hope it will benefit other DBIx::Class starters.

We have a lot of procedural code that we are looking to convert to DOM (Domain Object Modeling) and one of the tools we are lokoing to use is DBIx::Class (instead of writing our own Model which could be fun but a maintenance nightmare).

Anyway, the set up, we are look is mod_perl, DBIx::Class, MySQL backend, and some sort of MVC concept but we will not (for now) be using Catalyst (don't ask why).

Based on the above information my questions are:
1. ResultSet has a couple of methods related to caching, but going by the example given (http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/ResultSet.pm#cache)  it seems like you have to turn caching on a per search()/find() call, is there some way of turning it on for the whole class (even better all classes) in one place (i.e. Parent class that all other classes inherit from)? 
1.1 Is overriding/subclass resultset/ResultSet to capture search/find request to add the cache parameter an options to achieve the above?
2. Is there a different way to cache objects and/or ResultSet objects?
3. Can we cache SQL natively in DBIx::Class i.e. the SQL executed by a find, search or manual SELECT - I guess if 1 and 1.1 are supported SQL caching might be redundant except from manual SELECTs?
4. If there isn't native support for the above, can someone give me any advice and/or examples regarding using DBIx::Class and MemCache to achieve the same result?
5. I came across the module DBIx::Class::Cursor::Cached but since the documentation is a bit on the thin side, I was wondering if someone can explain it in a bit more detail.  For example is it possible to use it to achieve points 1/1.1 and also set a default cache_for periodf for a whole class, rather than individual search requests? 

Thanks in advance for your patience and help

Andreas Pronakis
DBIx::Class newbie but believer


      



More information about the DBIx-Class mailing list