« »
AnyData - A case study.
DBD::AnyData to the rescue!

We have a named constant at the top of our package, which determines if we will use caching or not.

  use constant CACHE_TABLES => 1;
  my $MEMORY_DBH;

Next, we check for that constant at compile time, and populate our cache if it exists.

  if ( CACHE_TABLES ) {
      $MEMORY_DBH = DBI->connect('dbi:AnyData:(RaiseError=>1)');
  
      foreach my $table ( PRICING_TABLE, QTY_DISCOUNT_TABLE,
                          INVENTORY_CLASS_TABLE, PRODUCT_TYPE_TABLE,
                          TRANSACTION_CODE_TABLE ) {
  
          my $dbh_pg = Pair::Nic::DBI->connect();
          my $query = sprintf ( "SELECT * FROM %s", $table );
          $MEMORY_DBH->func( $table, 'DBI', $dbh_pg, {sql=>$query}, 'ad_import' );
      }
  }

Copyright (c) 2004 pair Networks, Inc. | Daniel J. Wright