[Jifty-commit] r7574 - in Jifty-DBI/trunk/lib/Jifty/DBI: .
Jifty commits
jifty-commit at lists.jifty.org
Fri Oct 23 23:53:41 EDT 2009
Author: clkao
Date: Fri Oct 23 23:53:40 2009
New Revision: 7574
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
Log:
Make Jifty::DBI::Record::Cachable not to store cache during transaction, instead of trying (ineffectively) flushing the cache from handle level.
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm Fri Oct 23 23:53:40 2009
@@ -814,9 +814,6 @@
if ($force) {
$TRANSDEPTH = 0;
- Jifty::DBI::Record->flush_cache
- if Jifty::DBI::Record->can('flush_cache');
-
return ( $dbh->rollback );
}
@@ -831,9 +828,6 @@
return $TRANSDEPTH;
}
- Jifty::DBI::Record->flush_cache
- if Jifty::DBI::Record->can('flush_cache');
-
my $rv = $dbh->rollback;
if ($rv) {
$TRANSDEPTH--;
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm Fri Oct 23 23:53:40 2009
@@ -87,6 +87,11 @@
}
+sub _is_in_transaction {
+ my $self = shift;
+ $Jifty::DBI::Handle::TRANSDEPTH > 0;
+}
+
=head2 load_from_hash
Overrides the implementation from L<Jifty::DBI::Record> to add caching.
@@ -104,12 +109,12 @@
( $rvalue, $msg ) = $self->SUPER::load_from_hash(@_);
## Check the return value, if its good, cache it!
- $self->_store() if ($rvalue);
+ $self->_store() if ($rvalue && !$self->_is_in_transaction);
return ( $rvalue, $msg );
} else { # Called as a class method;
$self = $self->SUPER::load_from_hash(@_);
## Check the return value, if its good, cache it!
- $self->_store() if ( $self->id );
+ $self->_store() if ( $self->id && !$self->_is_in_transaction );
return ($self);
}
@@ -144,7 +149,7 @@
## Fetch from the DB!
my ( $rvalue, $msg ) = $self->SUPER::load_by_cols(%attr);
## Check the return value, if its good, cache it!
- if ($rvalue) {
+ if ($rvalue && !$self->_is_in_transaction) {
## Only cache the object if its okay to do so.
$self->_store();
$self->_key_cache->set(
More information about the Jifty-commit
mailing list