[Dbix-class] Caching DBIx-Class Fixtures

Ash Berlin ash_cpan at firemirror.com
Wed Jun 18 12:06:34 BST 2008


On 18 Jun 2008, at 11:38, Ovid wrote:

> Hi all,
>
> Pursuant to an idea I've outlined in
> http://use.perl.org/~Ovid/journal/36711, we're looking at caching some
> of our test fixtures.  While some might *require* being generated
> dynamically, many of our fixtures are in the following form:
>
>  get bbc4 id
>  create brand on bbc4
>  create series3 on brand
>  create episode2 on series3
>  create 2 versions of episode2
>  create episode3 on series3
>
> And so on.  In short, these are large fixture files with very static
> data being added to the database.  We feel that we can gain some
> significant benefits if we can cache the above in something like this:
>
>  -- md5:  ab523604f2f588df05389958560a042a
>
>  INSERT INTO brand ...
>
>  INSERT INTO series ...
>
> And so on.  The idea is that on the first run of a fixture, we'd run
> the code and cache the sql.  On subsequent runs, if the md5 of the  
> file
> hasn't changed, we'd just send the cached SQL directly to MySQL rather
> than run the code.
>
> I think this would require intercepting the SQL and bind parameters  
> and
> every fixture would have a file we'd cache this in.  Has anyone tried
> anything like this before?  How the heck would I get the SQL and bind
> params for something like?
>
> Or is there a much easier way of going about this?
>
> Cheers,
> Ovid

First thing I'd suggest is to look at DBIx::Class::Fixtures and see  
how close it comes to your needs. (I'm guessing you haven't looked at  
it yet judging by your useperl post)

-ash



More information about the DBIx-Class mailing list