ensembl-hive  2.7.0
Bio::EnsEMBL::DBSQL::Support::LruIdCache Class Reference
+ Inheritance diagram for Bio::EnsEMBL::DBSQL::Support::LruIdCache:

Public Member Functions

public Bio::EnsEMBL::DBSQL::Support::BaseCache new ()
 
public Int lru_size ()
 
public Bio::EnsEMBL::Utils::Cache build_cache ()
 
public Scalar get ()
 
public ArrayRef get_by_list ()
 
- Public Member Functions inherited from Bio::EnsEMBL::DBSQL::Support::BaseCache
public Bio::EnsEMBL::DBSQL::Support::BaseCache new ()
 
public Bio::EnsEMBL::DBSQL::BaseAdaptor adaptor ()
 
public Hash cache ()
 
public void delete_cache ()
 
public Scalar get ()
 
public ArrayRef get_by_list ()
 
public ArrayRef get_by_sql ()
 
public Scalar put ()
 
public Scalar remove ()
 
public void clear_cache ()
 
public List cache_keys ()
 
public List cached_values ()
 
public Int size ()
 
public Hash build_cache ()
 

Detailed Description

Synopsis

my $obj = $cache->put(1, 'a');
my $obj = $cache->put(2, 'b');
my $obj = $cache->put(3, 'c');
is_deeply([$cache->cache_keys()], ['b','c']); #ID 1 was ejected under LRU rules

Description

An implementation of caching which uses the oldest accessed key as the 
value to be ejected from the cache when the maximum size has been hit. See
the following page for more information about this algorithm

http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used

Definition at line 27 of file LruIdCache.pm.

Member Function Documentation

◆ build_cache()

public Bio::EnsEMBL::Utils::Cache Bio::EnsEMBL::DBSQL::Support::LruIdCache::build_cache ( )
  Description: Returns an instance of Bio::EnsEMBL::Utils::Cache and sized
               according to the return value in lru_cache()
  Returntype : Bio::EnsEMBL::Utils::Cache
  Exceptions : none
  Caller     : BaseAdaptors
  Status     : Beta
 
Code:
click to view

◆ get()

public Scalar Bio::EnsEMBL::DBSQL::Support::LruIdCache::get ( )
  Arg [1]    : String key to retrieve
  Example    :
$is($cache->get(1), 'a');
  Description: Retrieves the value held in the cache. If the value is not in
               the cache we will retrieve the value from 
               _uncached_fetch_by_dbID and then store that value
  Returntype : Scalar value held in the cache or nothing if the ID was not present
  Exceptions : If key was undefined
  Caller     : BaseAdaptors
  Status     : Beta
 
Code:
click to view

◆ get_by_list()

public ArrayRef Bio::EnsEMBL::DBSQL::Support::LruIdCache::get_by_list ( )
  Arg [1]    : ArrayRef keys to retrieve
  Arg [2]    : Bio::EnsEMBL::Slice optional attribute for 
               _uncached_fetch_all_by_dbID_list() delegation
  Example    :
is($cache->get_by_list([1,2]), ['a','b']);
  Description: Attempts to retrieve all values currently available in the cache,
               fetches any remaining values and stores these in the cache.
  Returntype : ArrayRef of found values
  Exceptions : None
  Caller     : BaseAdaptors
  Status     : Beta
 
Code:
click to view

◆ lru_size()

public Int Bio::EnsEMBL::DBSQL::Support::LruIdCache::lru_size ( )
  Arg [1]    : Int size of the cache
  Example    :
$cache->lru_size(10);
  Description: Resets the size of the cache and forces a rebuild of the cache 
               object to apply this new sizing. Also functions as a getter
  Returntype : Int
  Exceptions : none
  Caller     : BaseAdaptors
  Status     : Beta
 
Code:
click to view

◆ new()

public Bio::EnsEMBL::DBSQL::Support::BaseCache Bio::EnsEMBL::DBSQL::Support::LruIdCache::new ( )
  Arg [1]    : Bio::EnsEMBL::DBSQL::BaseAdaptor $db_adaptor
  Arg [2]    : Int size of the cache. Defaults to 1000
  Example    :
my $cache = Bio::EnsEMBL::DBSQL::Support::LruIdCache->new($db_adaptor, 10);
  Description: Creates a new cache class instance
  Returntype : Bio::EnsEMBL::DBSQL::Support::BaseCache
  Exceptions : none
  Caller     : BaseAdaptors
  Status     : Beta
 
Code:
click to view

The documentation for this class was generated from the following file:
Bio::EnsEMBL::DBSQL::Support::LruIdCache::build_cache
public Bio::EnsEMBL::Utils::Cache build_cache()
map
public map()
Bio::EnsEMBL::DBSQL::Support::LruIdCache::get
public Scalar get()
Bio::EnsEMBL::DBSQL::Support::LruIdCache::lru_size
public Int lru_size()
Bio::EnsEMBL::DBSQL::Support::BaseCache::put
public Scalar put()
Bio::EnsEMBL::DBSQL::Support::LruIdCache::get_by_list
public ArrayRef get_by_list()
Bio::EnsEMBL::DBSQL::Support::LruIdCache::new
public Bio::EnsEMBL::DBSQL::Support::BaseCache new()
Bio::EnsEMBL::DBSQL::Support::BaseCache::cache
public Hash cache()
Bio::EnsEMBL::DBSQL::Support::LruIdCache
Definition: LruIdCache.pm:27