Revision history for DBIx::Class::Cursor::Cached
+ - Refactor slightly to enable useful subclassing (RT#102223, Tim Bunce)
+
1.1.2 5 August 2011 15:47:00
- use Digest::SHA over Digest::SHA1 since it is core, RT #70092 (Salvatore Bonaccorso)
$conn = $connect_info->[0]->();
}
}
-
- local $Storable::canonical = 1;
- return Digest::SHA::sha1_hex(Storable::nfreeze( [ $ref, $conn->{Name}, $conn->{Username} || '' ] ));
+ return $class->_build_cache_key_hash([ $ref, $conn->{Name}, $conn->{Username} || '' ]);
+}
+
+sub _build_cache_key_hash {
+ my ($class, $key_data) = @_;
+ local $Storable::canonical = 1;
+ return Digest::SHA::sha1_hex(Storable::nfreeze( $key_data ));
}
sub _fill_data {
my $cache = $self->{cache_object};
my $key = $self->{cache_key};
return $cache->get($key) || do {
- my $data = [ $self->{inner}->all ];
+ my $data = $self->_fill_data_fetch_all();
$cache->set($key, $data, $self->{cache_for});
$data;
};
}
+sub _fill_data_fetch_all {
+ my ($self) = @_;
+ return [ $self->{inner}->all ];
+}
+
sub clear_cache {
my ($self) = @_;
$self->{cache_object}->remove($self->{cache_key});