Permalink
Browse files

new evition scheme

  • Loading branch information...
1 parent 78851f8 commit a5f18af4806219107373070533604a9f01dbaf4b @matiu committed May 19, 2011
Showing with 67 additions and 55 deletions.
  1. +6 −6 Makefile
  2. +14 −8 Makefile.old
  3. +47 −41 lib/SQL/Bibliosoph.pm
View
@@ -56,11 +56,11 @@ DIRFILESEP = /
DFSEP = $(DIRFILESEP)
NAME = SQL::Bibliosoph
NAME_SYM = SQL_Bibliosoph
-VERSION = 2.21
+VERSION = 2.30
VERSION_MACRO = VERSION
-VERSION_SYM = 2_21
+VERSION_SYM = 2_30
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
-XS_VERSION = 2.21
+XS_VERSION = 2.30
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
INST_ARCHLIB = blib/arch
@@ -269,7 +269,7 @@ RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
DIST_CP = best
DIST_DEFAULT = tardist
DISTNAME = SQL-Bibliosoph
-DISTVNAME = SQL-Bibliosoph-2.21
+DISTVNAME = SQL-Bibliosoph-2.30
# --- MakeMaker macro section:
@@ -496,7 +496,7 @@ metafile : create_distdir
$(NOECHO) $(ECHO) Generating META.yml
$(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml
$(NOECHO) $(ECHO) 'name: SQL-Bibliosoph' >> META_new.yml
- $(NOECHO) $(ECHO) 'version: 2.21' >> META_new.yml
+ $(NOECHO) $(ECHO) 'version: 2.30' >> META_new.yml
$(NOECHO) $(ECHO) 'abstract: A SQL Query library' >> META_new.yml
$(NOECHO) $(ECHO) 'author:' >> META_new.yml
$(NOECHO) $(ECHO) ' - Matias Alejo Garcia ( matiu@cpan.org ) ' >> META_new.yml
@@ -820,7 +820,7 @@ testdb_static :: testdb_dynamic
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd :
- $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="2.21">' > $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="2.30">' > $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <ABSTRACT>A SQL Query library</ABSTRACT>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <AUTHOR>Matias Alejo Garcia ( matiu@cpan.org ) </AUTHOR>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd
View
@@ -16,7 +16,7 @@
# BUILD_REQUIRES => { }
# MIN_PERL_VERSION => q[5.010000]
# NAME => q[SQL::Bibliosoph]
-# PREREQ_PM => { DBD::Mock=>undef, Package::Constants=>undef, Tie::Hash::Random=>q[1], Time::HiRes=>undef, Carp=>undef, Test::More=>q[0.88], DBD::mysql=>q[4.004], Digest::MD5=>q[2.39], Cache::Memcached::Fast=>q[0.17], Devel::Cover=>undef, Moose=>q[0.82], Tie::Array::Random=>q[1], DBI=>q[1.5] }
+# PREREQ_PM => { DBD::Mock=>undef, Package::Constants=>undef, Tie::Hash::Random=>q[1], Storable=>undef, Time::HiRes=>undef, Carp=>undef, Test::More=>q[0.88], DBD::mysql=>q[4.004], Digest::MD5=>q[2.39], Cache::Memcached::Fast=>q[0.17], Devel::Cover=>undef, Moose=>q[0.82], Tie::Array::Random=>q[1], DBI=>q[1.5] }
# VERSION_FROM => q[lib/SQL/Bibliosoph.pm]
# --- MakeMaker post_initialize section:
@@ -56,11 +56,11 @@ DIRFILESEP = /
DFSEP = $(DIRFILESEP)
NAME = SQL::Bibliosoph
NAME_SYM = SQL_Bibliosoph
-VERSION = 2.11
+VERSION = 2.22
VERSION_MACRO = VERSION
-VERSION_SYM = 2_11
+VERSION_SYM = 2_22
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
-XS_VERSION = 2.11
+XS_VERSION = 2.22
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
INST_ARCHLIB = blib/arch
@@ -187,10 +187,13 @@ PERL_ARCHIVE_AFTER =
TO_INST_PM = lib/SQL/Bibliosoph.pm \
lib/SQL/Bibliosoph/CatalogFile.pm \
+ lib/SQL/Bibliosoph/Dummy.pm \
lib/SQL/Bibliosoph/Query.pm \
lib/SQL/Bibliosoph/Sims.pm
-PM_TO_BLIB = lib/SQL/Bibliosoph/Query.pm \
+PM_TO_BLIB = lib/SQL/Bibliosoph/Dummy.pm \
+ blib/lib/SQL/Bibliosoph/Dummy.pm \
+ lib/SQL/Bibliosoph/Query.pm \
blib/lib/SQL/Bibliosoph/Query.pm \
lib/SQL/Bibliosoph.pm \
blib/lib/SQL/Bibliosoph.pm \
@@ -266,7 +269,7 @@ RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
DIST_CP = best
DIST_DEFAULT = tardist
DISTNAME = SQL-Bibliosoph
-DISTVNAME = SQL-Bibliosoph-2.11
+DISTVNAME = SQL-Bibliosoph-2.22
# --- MakeMaker macro section:
@@ -493,7 +496,7 @@ metafile : create_distdir
$(NOECHO) $(ECHO) Generating META.yml
$(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml
$(NOECHO) $(ECHO) 'name: SQL-Bibliosoph' >> META_new.yml
- $(NOECHO) $(ECHO) 'version: 2.11' >> META_new.yml
+ $(NOECHO) $(ECHO) 'version: 2.22' >> META_new.yml
$(NOECHO) $(ECHO) 'abstract: A SQL Query library' >> META_new.yml
$(NOECHO) $(ECHO) 'author:' >> META_new.yml
$(NOECHO) $(ECHO) ' - Matias Alejo Garcia ( matiu@cpan.org ) ' >> META_new.yml
@@ -514,6 +517,7 @@ metafile : create_distdir
$(NOECHO) $(ECHO) ' Moose: 0.82' >> META_new.yml
$(NOECHO) $(ECHO) ' Package::Constants: ~' >> META_new.yml
$(NOECHO) $(ECHO) ' perl: 5.010000' >> META_new.yml
+ $(NOECHO) $(ECHO) ' Storable: ~' >> META_new.yml
$(NOECHO) $(ECHO) ' Test::More: 0.88' >> META_new.yml
$(NOECHO) $(ECHO) ' Tie::Array::Random: 1' >> META_new.yml
$(NOECHO) $(ECHO) ' Tie::Hash::Random: 1' >> META_new.yml
@@ -816,7 +820,7 @@ testdb_static :: testdb_dynamic
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd :
- $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="2.11">' > $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="2.22">' > $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <ABSTRACT>A SQL Query library</ABSTRACT>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <AUTHOR>Matias Alejo Garcia ( matiu@cpan.org ) </AUTHOR>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd
@@ -830,6 +834,7 @@ ppd :
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Digest::MD5" VERSION="2.39" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Moose::" VERSION="0.82" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Package::Constants" />' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' <REQUIRE NAME="Storable::" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Test::More" VERSION="0.88" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Tie::Array::Random" VERSION="1" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <REQUIRE NAME="Tie::Hash::Random" VERSION="1" />' >> $(DISTNAME).ppd
@@ -844,6 +849,7 @@ ppd :
pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
$(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \
+ lib/SQL/Bibliosoph/Dummy.pm blib/lib/SQL/Bibliosoph/Dummy.pm \
lib/SQL/Bibliosoph/Query.pm blib/lib/SQL/Bibliosoph/Query.pm \
lib/SQL/Bibliosoph.pm blib/lib/SQL/Bibliosoph.pm \
lib/SQL/Bibliosoph/Sims.pm blib/lib/SQL/Bibliosoph/Sims.pm \
View
@@ -10,7 +10,7 @@ package SQL::Bibliosoph; {
use SQL::Bibliosoph::Query;
use SQL::Bibliosoph::CatalogFile;
- our $VERSION = "2.22";
+ our $VERSION = "2.30";
has 'dbh' => ( is => 'ro', isa => 'DBI::db', required=> 1);
@@ -110,34 +110,43 @@ package SQL::Bibliosoph; {
$self->create_methods_from($qs);
}
- sub get_subfix {
- my ($self,$group, $ttl) = @_;
-
- my $subfix = $^T;
-
- if (my $r = $self->memc()->get($group)) {
- $subfix = $r;
- }
- else {
- $self->memc()->set($group, $subfix, $ttl);
- }
-
- return '-v' . $subfix;
- }
-
-
sub expire_group {
my ($self, $group) = @_;
if ( $self->memc() ) {
$self->d("Expiring group $group\n");
- $self->memc()->incr($group,1);
+
+
+ my $md5s = $self->memc()->get($group . '-g');
+ foreach (split /:/, $md5s) {
+ next if ! $_;
+
+#$self->d("\t\t expiring query in group $group : $_");
+
+ $self->memc()->delete($_);
+ }
+ $self->memc()->delete( $group . '-g' );
}
else {
$self->d("Could not expire \"$group\" -> Memcached not configured\n");
}
}
+
+ sub add_to_group {
+ my ($self, $group, $md5, $md5c) = @_;
+
+ $group = $group . '-g';
+ $md5 .= ':' . $md5c if $md5c;
+ $md5 .= ':';
+
+ $self->memc()->append( $group, $md5)
+ || $self->memc()->set( $group, $md5)
+ ;
+
+#$self->d("\t\t storing query in group ".$group ."$md5");
+ }
+
sub create_methods_from {
my ($self,$q) = @_;
@@ -242,22 +251,16 @@ package SQL::Bibliosoph; {
## check memcached
my $md5 = md5_hex( join ('', $name, map { $_ // 'NULL' } @_ ));
- $md5 .= $self->get_subfix($cfg->{group}, $cfg->{ttl})
- if $cfg->{group};
-
-
my $ret;
if (! $cfg->{force} ) {
$ret = $self->memc()->get($md5);
-
}
else {
- $self->d("\n\t[forced to run SQL query & store result in memc 2]\n");
+ $self->d("\n\t[forced to run SQL query & store result in memc (rowh)]\n");
}
if (! defined $ret ) {
- #$self->d("\t[running SQL & storing memc $md5]\n");
$self->d("\t[running SQL & storing memc]\n");
#print "cfg:" . Dumper($cfg);
@@ -267,7 +270,13 @@ package SQL::Bibliosoph; {
#print "AFTER: ret:" . Dumper($ret);
# $ret could be undefined is query had an error!
- $self->memc()->set($md5, $ret, $ttl) if defined $ret;
+ if (defined $ret) {
+ $self->memc()->set($md5, $ret, $ttl);
+
+ $self->add_to_group($cfg->{group}, $md5) if $cfg->{group};
+ }
+
+ ##
}
else {
$self->d("\t[from memc]\n");
@@ -334,17 +343,13 @@ package SQL::Bibliosoph; {
my ($val, $count);
my $md5 = md5_hex( join ('', $name, map { $_ // 'NULL' } @_ ));
my $md5c = $md5 . '_count';
+
if (! $cfg->{force} ) {
## check memcached
my $ret = {};
- if ( $cfg->{group} ) {
- my $s = $self->get_subfix($cfg->{group}, $cfg->{ttl});
- $md5 .= $s;
- $md5c .= $s;
- }
-
$ret = $self->memc()->get_multi($md5, $md5c) ;
+
if ($ret) {
$val = $ret->{$md5};
$count = $ret->{$md5c};
@@ -353,16 +358,22 @@ package SQL::Bibliosoph; {
else {
$self->d("\t[forced to run SQL query & store result in memc]\n");
}
+
if (! defined $val ) {
$self->d("\t[running SQL & storing memc]\n");
($val, $count)
= $self->queries()->{$name}->select_many2([@_],{});
- $self->memc()->set_multi(
- [ $md5, $val, $ttl],
- [ $md5c, $count, $ttl],
- ) if defined $val;
+ if ( defined $val) {
+ $self->memc()->set_multi(
+ [ $md5, $val, $ttl],
+ [ $md5c, $count, $ttl],
+ );
+
+
+ $self->add_to_group($cfg->{group}, $md5, $md5c ) if $cfg->{group};
+ }
}
else {
$self->d("\t[from memc]\n");
@@ -458,13 +469,8 @@ package SQL::Bibliosoph; {
}
$self->d("\tPrepared $i Statements". ( $self->delayed() ? " (delayed) " : '' ). "\n");
}
-
-
-
}
-
-
1;
__END__

0 comments on commit a5f18af

Please sign in to comment.