/[Frey]/trunk/lib/Strix/Schema.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Strix/Schema.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations)
Sun Jun 29 00:49:50 2008 UTC (15 years, 9 months ago) by dpavlin
File size: 620 byte(s)
implement schema caching using Storable
to reduce test time from 26s to 6s
1 dpavlin 2 package Strix::Schema;
2    
3     use Fey::DBIManager;
4     use Fey::DBIManager::Source;
5     use Fey::Loader;
6     use Fey::ORM::Schema;
7    
8 dpavlin 15 use Storable;
9     use Data::Dump qw/dump/;
10    
11     my $schema_file = 'var/schema.storable';
12    
13 dpavlin 12 my $source = Fey::DBIManager::Source->new( dsn => 'dbi:Pg:dbname=new' );
14 dpavlin 2
15 dpavlin 15 my $schema;
16     if ( -e $schema_file ) {
17     $schema = retrieve $schema_file or die "can't read schema from $schema_file: $!";
18     } else {
19     $schema= Fey::Loader->new( dbh => $source->dbh() )->make_schema();
20     store $schema, $schema_file or warn "can't store schema into $schema_file: $!";
21     }
22 dpavlin 2
23     has_schema $schema;
24    
25     __PACKAGE__->DBIManager()->add_source($source);

  ViewVC Help
Powered by ViewVC 1.1.26