Skip to content
Snippets Groups Projects
Commit 198edb6f authored by Kieron Taylor's avatar Kieron Taylor :angry:
Browse files

Added a no_cache override feature plus testcase. Useful in times of memory...

Added a no_cache override feature plus testcase. Useful in times of memory crisis coupled with annoyingly slow lookups of small data.
parent 06d2602f
No related branches found
No related tags found
No related merge requests found
......@@ -752,7 +752,7 @@ sub last_insert_id {
sub _id_cache {
my ($self) = @_;
return if $self->db()->no_cache();
return if $self->db()->no_cache() && !$self->ignore_cache_override;
if(! exists $self->{_id_cache}) {
$self->{_id_cache} = $self->_build_id_cache();
}
......@@ -774,6 +774,21 @@ sub _no_id_cache {
return 0;
}
=head2 ignore_cache_override
Description : Method to interfere with no_cache directive from Registry on
a per adaptor basis. This method should be called after new()
in order to trigger the _build_id_cache at first query.
Example : $adaptor->ignore_cache_override(1);
Returntype : Boolean
=cut
sub ignore_cache_override {
my $self = shift;
$self->{'_override'} = shift if(@_);
unless (defined($self->{'_override'})) {return}
return $self->{'_override'};
}
#_tables
#
......
......@@ -74,6 +74,15 @@ sub BEGIN {
isnt($adaptor->fetch_all_by_dbID_list([$gene_ids->[0]])->[0], $cached_obj, 'Checking two objects are no longer the same as the cache is off');
$adaptor->db()->no_cache(0);
# Negating no_cache
$cached_obj = $adaptor->fetch_by_dbID($gene_ids->[0]);
$adaptor->db()->no_cache(1);
$adaptor->ignore_cache_override(1);
is($adaptor->fetch_by_dbID($gene_ids->[0]), $cached_obj, 'Checking no_cache can be ignored.');
$adaptor->db()->no_cache(0);
$adaptor->ignore_cache_override(0);
#hit seq region cache & check we clear that one out as well
$adaptor->fetch_all_by_Slice($genes->[0]->slice());
$adaptor->clear_cache();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment