r61529 - in /trunk/liborlite-perl: Changes MANIFEST META.yml README debian/changelog debian/control debian/copyright lib/ORLite.pm t/08_prune.pl t/17_cache.sql t/17_cache.t t/lib/Test.pm

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Thu Aug 12 13:54:03 UTC 2010


Author: angelabad-guest
Date: Thu Aug 12 13:53:51 2010
New Revision: 61529

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=61529
Log:
New upstream release 1.45

Added:
    trunk/liborlite-perl/t/17_cache.sql
      - copied unchanged from r61528, branches/upstream/liborlite-perl/current/t/17_cache.sql
    trunk/liborlite-perl/t/17_cache.t
      - copied unchanged from r61528, branches/upstream/liborlite-perl/current/t/17_cache.t
Modified:
    trunk/liborlite-perl/Changes
    trunk/liborlite-perl/MANIFEST
    trunk/liborlite-perl/META.yml
    trunk/liborlite-perl/README
    trunk/liborlite-perl/debian/changelog
    trunk/liborlite-perl/debian/control
    trunk/liborlite-perl/debian/copyright
    trunk/liborlite-perl/lib/ORLite.pm
    trunk/liborlite-perl/t/08_prune.pl
    trunk/liborlite-perl/t/lib/Test.pm

Modified: trunk/liborlite-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/Changes?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/Changes (original)
+++ trunk/liborlite-perl/Changes Thu Aug 12 13:53:51 2010
@@ -1,4 +1,7 @@
 Changes for Perl extension ORLite
+
+1.45 Sun  8 Aug 2010
+	- Adding initial support for cache => $directory (ADAMK)
 
 1.44 Fri 23 Jul 2010
 	- Upgrading to Module::Install::DSL 1.00 (ADAMK)

Modified: trunk/liborlite-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/MANIFEST?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/MANIFEST (original)
+++ trunk/liborlite-perl/MANIFEST Thu Aug 12 13:53:51 2010
@@ -36,6 +36,8 @@
 t/14_array_fk.t
 t/15_array_xs.t
 t/16_array_create.t
+t/17_cache.sql
+t/17_cache.t
 t/lib/Test.pm
 xt/meta.t
 xt/pmv.t

Modified: trunk/liborlite-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/META.yml?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/META.yml (original)
+++ trunk/liborlite-perl/META.yml Thu Aug 12 13:53:51 2010
@@ -35,4 +35,4 @@
   ChangeLog: http://fisheye2.atlassian.com/changelog/cpan/trunk/ORLite
   license: http://dev.perl.org/licenses/
   repository: http://svn.ali.as/cpan/trunk/ORLite
-version: 1.44
+version: 1.45

Modified: trunk/liborlite-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/README?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/README (original)
+++ trunk/liborlite-perl/README Thu Aug 12 13:53:51 2010
@@ -222,6 +222,18 @@
     class for every table in the main schema that is not prefixed with with
     "sqlite_".
 
+  cache
+      use ORLite {
+          file         => 'dbi:SQLite:sqlite.db',
+          user_version => 2,
+          cache        => 'cache/directory',
+      };
+
+    The "cache" option is used to reduce the time needed to scan the SQLite
+    database table structures and generate the code for them, by saving the
+    generated code to a cache directory and loading from that file instead
+    of generating it each time from scratch.
+
   cleanup
     When working with embedded SQLite database containing rapidly changing
     state data, it is important for database performance and general health

Modified: trunk/liborlite-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/debian/changelog?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/debian/changelog (original)
+++ trunk/liborlite-perl/debian/changelog Thu Aug 12 13:53:51 2010
@@ -1,3 +1,12 @@
+liborlite-perl (1.45-1) unstable; urgency=low
+
+  * New upstream release
+  * Add myself to uploaders
+  * debian/control: Add libfile-path-perl (>= 2.04) to B-D-I
+  * Update copyright file
+
+ -- Angel Abad <angelabad at gmail.com>  Thu, 12 Aug 2010 15:53:17 +0200
+
 liborlite-perl (1.44-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/liborlite-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/debian/control?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/debian/control (original)
+++ trunk/liborlite-perl/debian/control Thu Aug 12 13:53:51 2010
@@ -10,7 +10,8 @@
  Brian Cassidy <brian.cassidy at gmail.com>, Rene Mayorga <rmayorga at debian.org>,
  Jaldhar H. Vyas <jaldhar at debian.org>, Nathan Handler <nhandler at ubuntu.com>,
  Jonathan Yu <jawnsy at cpan.org>, gregor herrmann <gregoa at debian.org>,
- Ansgar Burchardt <ansgar at 43-1.org>, Franck Joncourt <franck at debian.org>
+ Ansgar Burchardt <ansgar at 43-1.org>, Franck Joncourt <franck at debian.org>,
+ Angel Abad <angelabad at gmail.com>
 Standards-Version: 3.9.1
 Homepage: http://search.cpan.org/dist/ORLite/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/liborlite-perl/
@@ -19,8 +20,9 @@
 Package: liborlite-perl
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends}, libdbd-sqlite3-perl (>= 1.27),
- libdbi-perl (>= 1.607), perl (>= 5.10.1) | libfile-temp-perl (>= 0.20),
- libparams-util-perl (>= 0.33), libfile-remove-perl
+ libdbi-perl (>= 1.607), libfile-remove-perl (>= 1.40),
+ libparams-util-perl (>= 0.33), libfile-path-perl (>= 2.04),
+ perl (>= 5.10.1) | libfile-temp-perl (>= 0.20)
 Suggests: libclass-xsaccessor-perl
 Description: lightweight SQLite-specific ORM
  ORLite is a Perl module that implements an object-relational mapper designed

Modified: trunk/liborlite-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/debian/copyright?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/debian/copyright (original)
+++ trunk/liborlite-perl/debian/copyright Thu Aug 12 13:53:51 2010
@@ -14,13 +14,15 @@
 License: Artistic or GPL-1+
 
 Files: debian/*
-Copyright: 2008, 2009, Brian Cassidy <brian.cassidy at gmail.com>
+Copyright: 2008-2009, Brian Cassidy <brian.cassidy at gmail.com>
  2008, Damyan Ivanov <dmn at debian.org>
  2008, Gunnar Wolf <gwolf at debian.org>
- 2009, 2010, Jonathan Yu <jawnsy at cpan.org>
+ 2009-2010, Jonathan Yu <jawnsy at cpan.org>
  2009, Jaldhar H. Vyas <jaldhar at debian.org>
  2009, Nathan Handler <nhandler at ubuntu.com>
  2009, Rene Mayorga <rmayorga at debian.org>
+ 2010, Angel Abad <angelabad at gmail.com>
+ 2010, Ansgar Burchardt <ansgar at 43-1.org>
  2010, Franck Joncourt <franck at debian.org>
  2010, gregor herrmann <gregoa at debian.org>
 License: Artistic or GPL-1+
@@ -30,7 +32,7 @@
  it under the terms of the Artistic License, which comes with Perl.
  .
  On Debian GNU/Linux systems, the complete text of the Artistic License
- can be found in `/usr/share/common-licenses/Artistic'
+ can be found in `/usr/share/common-licenses/Artistic'.
 
 License: GPL-1+
  This program is free software; you can redistribute it and/or modify
@@ -38,5 +40,5 @@
  the Free Software Foundation; either version 1, or (at your option)
  any later version.
  .
- On Debian GNU/Linux systems, the complete text of the GNU General
- Public License can be found in `/usr/share/common-licenses/GPL-1'
+ On Debian GNU/Linux systems, the complete text of version 1 of the
+ General Public License can be found in `/usr/share/common-licenses/GPL-1'.

Modified: trunk/liborlite-perl/lib/ORLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/lib/ORLite.pm?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/lib/ORLite.pm (original)
+++ trunk/liborlite-perl/lib/ORLite.pm Thu Aug 12 13:53:51 2010
@@ -14,7 +14,7 @@
 
 use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '1.44';
+	$VERSION = '1.45';
 }
 
 # Support for the 'prune' option
@@ -45,7 +45,7 @@
 	}
 
 	# Check params and apply defaults
-	my %params;
+	my %params = ();
 	if ( defined Params::Util::_STRING($_[1]) ) {
 		# Support the short form "use ORLite 'db.sqlite'"
 		%params = ( file => $_[1] );
@@ -89,11 +89,44 @@
 		Carp::croak("Missing or invalid package class");
 	}
 
-	# Connect to the database
+	# Check caching params
+	my $cached = undef;
+	my $pkg    = $params{package};
+	if ( defined $params{cache} ) {
+		# Caching is illogical or invalid in some situations
+		if ( $params{prune} ) {
+			Carp::croak("Cannot set a 'cache' directory while 'prune' enabled");
+		}
+		unless ( $params{user_version} ) {
+			Carp::croak("Cannot set a 'cache' directory without 'user_version'");
+		}
+
+		# To make the caching work, the version be defined before ORLite is called.
+		no strict 'refs';
+		unless ( ${"$pkg\::VERSION"} ) {
+			Carp::croak("Cannot set a 'cache' directory without a package \$VERSION");
+		}
+
+		# Build the cache file from the super path using an inlined Class::ISA
+		my @queue = ( $class );
+		my %seen  = ( $pkg => 1 );
+		my @parts = ( $pkg => ${"$pkg\::VERSION"} );
+		while ( @queue ) {
+			my $c = Params::Util::_STRING(shift @queue) or next;
+			push @parts, $c => ${"$c\::VERSION"};
+			unshift @queue, grep { not $seen{$c}++ } @{"$c\::ISA"};
+		}
+		$cached = join '-', @parts, user_version => $params{user_version};
+		$cached =~ s/[:.-]+/-/g;
+		$cached = File::Spec->rel2abs(
+			File::Spec->catfile( $params{cache}, "$cached.pm" )
+		);
+	}
+
+	# Create the parent directory if needed
 	my $file    = File::Spec->rel2abs($params{file});
 	my $created = ! -f $params{file};
 	if ( $created ) {
-		# Create the parent directory
 		my $dir = File::Basename::dirname($file);
 		unless ( -d $dir ) {
 			my @dirs = File::Path::mkpath( $dir, { verbose => 0 } );
@@ -101,7 +134,34 @@
 		}
 		$class->prune($file) if $params{prune};
 	}
-	my $pkg        = $params{package};
+
+	# Connect to the database
+	my $dsn = "dbi:SQLite:$file";
+	my $dbh = DBI->connect( $dsn, undef, undef, {
+		PrintError => 0,
+		RaiseError => 1,
+	} );
+
+	# Schema custom creation support
+	if ( $created and Params::Util::_CODELIKE($params{create}) ) {
+		$params{create}->( $dbh );
+	}
+
+	# Check the schema version before generating
+	my $user_version = $dbh->selectrow_arrayref('pragma user_version')->[0];
+	if ( exists $params{user_version} and $user_version != $params{user_version} ) {
+		Carp::croak("Schema user_version mismatch (got $user_version, wanted $params{user_version})");
+	}
+
+	# If caching and the cached version exists, load and shortcut.
+	# Don't try to catch exceptions, just let them blow up.
+	if ( $cached and -f $cached ) {
+		$dbh->disconnect;
+		require $cached;
+		return 1;
+	}
+
+	# Prepare to generate code
 	my $readonly   = $params{readonly};
 	my $cleanup    = $params{cleanup};
 	my $xsaccessor = $params{xsaccessor};
@@ -111,22 +171,6 @@
 	my $r          = $array ? ']'  : '}';
 	my $slice      = $array ? '{}' : '{ Slice => {} }';
 	my $rowref     = $array ? 'arrayref' : 'hashref';
-	my $dsn        = "dbi:SQLite:$file";
-	my $dbh        = DBI->connect( $dsn, undef, undef, {
-		PrintError => 0,
-		RaiseError => 1,
-	} );
-
-	# Schema creation support
-	if ( $created and Params::Util::_CODELIKE($params{create}) ) {
-		$params{create}->( $dbh );
-	}
-
-	# Check the schema version before generating
-	my $user_version  = $dbh->selectrow_arrayref('pragma user_version')->[0];
-	if ( exists $params{user_version} and $user_version != $params{user_version} ) {
-		Carp::croak("Schema user_version mismatch (got $user_version, wanted $params{user_version})");
-	}
 
 	# Generate the support package code
 	my $code = <<"END_PERL";
@@ -586,6 +630,20 @@
 	}
 	$code .= "\n\n1;\n";
 
+	# Save to the cache location if caching is enabled
+	if ( $cached ) {
+		my $dir = File::Basename::dirname($cached);
+		unless ( -d $dir ) {
+			File::Path::mkpath( $dir, { verbose => 0 } );
+		}
+
+		# Save a copy of the code to the file
+		local *FILE;
+		open( FILE, ">$cached" ) or Carp::croak("open($cached): $!");
+		print FILE $code;
+		close FILE;
+	}
+
 	# Compile the code
 	local $@;
 	if ( $^P and $^V >= 5.008009 ) {
@@ -612,14 +670,14 @@
 	unlink $filename;
 
 	# Print the debugging output
-	my @trace = map {
-		s/\s*[{;]$//;
-		s/^s/  s/;
-		s/^p/\np/;
-		"$_\n"
-	} grep {
-		/^(?:package|sub)\b/
-	} split /\n/, $_[0];
+	# my @trace = map {
+		# s/\s*[{;]$//;
+		# s/^s/  s/;
+		# s/^p/\np/;
+		# "$_\n"
+	# } grep {
+		# /^(?:package|sub)\b/
+	# } split /\n/, $_[0];
 	# print STDERR @trace, "\nCode saved as $filename\n\n";
 
 	return 1;
@@ -865,6 +923,19 @@
 a class for every table in the main schema that is not prefixed with 
 with C<sqlite_>.
 
+=head2 cache
+
+  use ORLite {
+      file         => 'dbi:SQLite:sqlite.db',
+      user_version => 2,
+      cache        => 'cache/directory',
+  };
+
+The C<cache> option is used to reduce the time needed to scan the SQLite
+database table structures and generate the code for them, by saving the
+generated code to a cache directory and loading from that file instead
+of generating it each time from scratch.
+
 =head2 cleanup
 
 When working with embedded SQLite database containing rapidly changing

Modified: trunk/liborlite-perl/t/08_prune.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/08_prune.pl?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/t/08_prune.pl (original)
+++ trunk/liborlite-perl/t/08_prune.pl Thu Aug 12 13:53:51 2010
@@ -4,7 +4,7 @@
 
 use strict;
 
-our $VERSION = '1.44';
+our $VERSION = '1.45';
 
 unless ( $ORLite::VERSION eq $VERSION ) {
 	die('Failed to load correct ORLite version');

Modified: trunk/liborlite-perl/t/lib/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/lib/Test.pm?rev=61529&op=diff
==============================================================================
--- trunk/liborlite-perl/t/lib/Test.pm (original)
+++ trunk/liborlite-perl/t/lib/Test.pm Thu Aug 12 13:53:51 2010
@@ -9,7 +9,7 @@
 
 use vars qw{$VERSION @ISA @EXPORT};
 BEGIN {
-	$VERSION = '1.44';
+	$VERSION = '1.45';
 	@ISA     = 'Exporter';
 	@EXPORT  = qw{ test_db connect_ok create_ok };
 }




More information about the Pkg-perl-cvs-commits mailing list