Apache-DBI-Cache

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Apache::DBI::Cache - a DBI connection cache

SYNOPSIS
      use Apache::DBI::Cache debug=>3, bdb_env=>'/tmp/tmp',
                             plugin=>'Apache::DBI::Cache::mysql',
                             plugin=>['DBM', sub {...}, sub {...}],
                             ...;

INSTALLATION
    This installs 2 modules "Apache::DBI::Cache" und
    "Apache::DBI::Cache::mysql".

     perl Makefile.PL
     make
     make test
     make install

  Testing
   MySQL
    Since Apache::DBI::Cache::mysql depends on MySQL you need 2 databases on
    the same DB server listening on port 3306 to test it. Nothing will be
    written to them. Only connections are established and the "SHOW
    PROCESSLIST" command is executed.

    The connection parameters are passed to the test as environment
    variables. If you do not want to test it leave them empty and the plugin
    test ("t/100mysql") is silently skipped.

    These environment variables are used:

    MYSQL1, MYSQL2
        the 2 database names

    MYSQL_HOST
        the database host. If omitted "localhost" is used.

    MYSQL_USER, MYSQL_PASSWD
        you credentials.

    My "make test" command looks like:

     MYSQL1=dbitest1 MYSQL2=dbitest2 make test

   BerkeleyDB
    If "BerkeleyDB" is not available a few tests are skipped.

DEPENDENCIES
    BerkeleyDB is used if installed to make DBI handle statistics visible
    for the whole Apache process group instead of a single process.

    DBI 1.37

    perl 5.8.0

DESCRIPTION
    This module is an alternative to the famous Apache::DBI module. As
    Apache::DBI it provides persistent DBI connections.

    It can be used with mod_perl1, mod_perl2 and even standalone.

  WHY ANOTHER MODULE FOR THE SAME?
    Apache::DBI has a number of limitations. Firstly, it is not possible to
    get multiple connections with the same parameters. A common scenario for
    example is to use one connection to perform transactions and another to
    perform simple lookups in the same database. With Apache::DBI it is very
    likely to get the same connection if you mean to use different.

    With Apache::DBI all connections are reset at end of a request.

    Apache::DBI does not regard database specific functions to cache handles
    more aggressively. For example a mysql DSN can look like

     dbi:mysql:test:localhost:3306

    or

     dbi:mysql:host=localhost;db=test

    Both point to the same database but for Apache::DBI they are different.
    Apache::DBI::Cache recognizes these two by means of a *mysql* plugin.

    The plugin even recognizes connections to different databases on the
    same mysql server as the same connection and issues a "USE database"
    command before returning the actual handle to the user. Hence, with
    Apache::DBI::Cache many the overall number of connections to a DB server
    can be dramatically reduced.

  HOW DOES IT WORK?
    To decide whether to use Apache::DBI::Cache or not it is essential to
    know how it works. As with Apache::DBI Apache::DBI::Cache uses a hook
    provided by the DBI module to intercept "DBI->connect()" calls. Also do
    Apache::DBI::Cache maintain a cache of active handles.

    When a new connection is requested and the cache is empty a new
    connection is established and returned to the user. At this point it is
    not cached at all. Here Apache::DBI::Cache differs from Apache::DBI.

    Later either "disconnect" is called on the handle or it simply goes out

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.918 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )