Apache2::Translation::DB - A provider for Apache2::Translation
<TranslationProvider DB> Database dbi:mysql:dbname:host User username Password password Singleton 1 Table tablename Key keycolumn Uri uricolumn Block blockcolumn Order ordercolumn Action actioncolumn Cachetbl cachetablename Cachecol cachecolumn Cachesize 1000 </TranslationProvider> or $provider=Apache2::Translation::DB->new(Database=>..., ...); $provider->start; $provider->stop;
The DB provider implements the Apache2::Translation provider interface as documented in Apache2::Translation::_base. It provides for all optional functions. No additional functions are supported.
DB
Apache2::Translation
a string describing a DBI database
the user and password to use
names the translation table.
name the columns of the translation table to use. The id and notes columns are necessary only in combination with the admin interface. The id column if specified must have a default value on INSERT generating unique keys, something like autoincrement in MySQL or nextval('sequence') in PostgreSQL.
id
notes
INSERT
autoincrement
nextval('sequence')
name the cache table and its column
sets the maximum number of cached block lists, default is 1000.
If set to infinite the cache has no limits.
infinite
A Tie::Cache::LRU cache is used.
Apache2::Translation::DB caches database entries as lists of blocks. Each list of blocks consumes one cache entry.
Apache2::Translation::DB
For each request first the following lookup is done:
SELECT MAX($cachecol) FROM $cachetbl
The resulting value is then compared with the previous read value. If it has changed, it means the cache is invalid. If not, the cache is valid and if all information is found in the cache, no further database lookups are needed.
Normally, Apache2::Translation tries to connect to the database at server startup. Then it inspects the database handle to see if Apache::DBI or Apache::DBI::Cache are loaded. If so, it will connect and disconnect for each translation phase / request, thus, put back the connection to the connection pool.
Apache::DBI
Apache::DBI::Cache
If neither of them is loaded the DB connection is used as a singleton. It is connected once at server startup and then held open (and reconnected if dropped by the database server).
With the optional singleton parameter you can decide to use a singleton connection even if a connection pool is in effect. If no connection pool is loaded, then of course setting singleton to false has no effect.
singleton
Torsten Foertsch, <torsten.foertsch@gmx.net>
Copyright (C) 2005-2008 by Torsten Foertsch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Apache2::Translation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache2::Translation
CPAN shell
perl -MCPAN -e shell install Apache2::Translation
For more information on module installation, please visit the detailed CPAN module installation guide.