LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CONTACT

Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.

NAME

Bio::EnsEMBL::DBSQL::Support::FullIdCache - ID based caching using all available values

SYNOPSIS

my $cache = Bio::EnsEMBL::DBSQL::Support::FullIdCache->new($adaptor);
my $obj = $cache->get(21);

DESCRIPTION

An implementation of caching which uses a raw hash to hold all available values from an adaptor. Useful for working with a controlled vocabulary table where cardinality is low.

Provides extra functionality to compute additional lookup keys.

METHODS

build_cache

Description: Builds a cache keyed by dbID and populated from a call
             using C<generic_fetch()>
Returntype : Hash
Exceptions : None
Caller     : BaseAdaptors
Status     : Beta

get_by_additional_lookup

Arg [1]     : String key of the lookup to search for the value in
Arg [2]     : String value to search for. We expect exact lookups in the hash
Description : Returns the object linked to the value in the specified lookup.
Example     : my $analysis = $cache->get_by_additional_lookup('logic_name', 'xrefchecksum');
Returntype  : Object a single object
Exceptions  : Throws an exception if there are more than one ID linked to the
              value lookup. Also thrown if additional lookups are not supported 
Caller      : BaseAdaptors
Status      : Beta

get_all_by_additional_lookup

Arg [1]     : String key of the lookup to search for the value in
Arg [2]     : String value to search for. We expect exact lookups in the hash
Description : Returns an array of all the objects linked to the value
              in the specified lookup.
Example     : my $array = $cache->get_all_by_additional_lookup('logic_name', 'xrefchecksum');
Returntype  : ArrayRef of objects keyed agains the second argument
Exceptions  : Throws an exception if there are more than one ID linked to the
              value lookup. Also thrown if additional lookups are not supported
Caller      : BaseAdaptors
Status      : Beta

remove_from_additional_lookup

Arg [1]     : String The lookup key to remove from the additional lookup hash
Arg [2]     : Object The object to remove from the additional lookup hash
Description : Re-computes the additional keys for this object 
Example     : $cache->remove_Object_from_additional_lookup($lookup_key, $object);
Returntype  : None
Exceptions  : Thrown if we do not support additional lookups
Caller      : BaseAdaptors
Status      : Beta

compute_keys

Arg [1]     : Object The object to compute keys from
Description : Override to provide support for additional key lookup. The
              keys of the hash should represent the lookup name and the
              value is the computed key.
Example     : Example of returning hash not of its usage. Proposed Analysis encoding
              { logic_name => 'xrefalignment', display_label => 'Xref Alignment'}
Returntype  : HashRef key is the lookup name and value is the computed key
Exceptions  : none
Caller      : BaseAdaptors
Status      : Beta

add_to_additional_lookups

Arg [1]     : String The key used in the primary lookup hash. Normally
              a DB identifier
Arg [2]     : Object The object to add to the additional lookups
Description : Internally calls the C<compute_keys()> method and adds
              the object to the C<_additional_lookup()> hash.
Returntype  : None
Exceptions  : Thrown if additional lookups are not supported
Caller      : BaseAdaptors
Status      : Beta

_additional_lookup

Description : Returns the additional lookup hash
Example     : Example of additional hash structure (key is 
              lookup name, second key is value to search for
              and value is an array of dbIDs)
              {
                logic_name => {
                  xrefalignment => [1]
                },
                display_label => {
                  'Xref Alignment' => [1]
                }
              }
Returntype  : HashRef
Exceptions  : none
Caller      : BaseAdaptors
Status      : Beta