Apache-DBI-Cache
view release on metacpan or search on metacpan
...;
* plugin
loads a plugin, see also "PLUGINS" below. The plugin can be
specified as a 3-element array or by name. In the second case the
"import" simply "use"s the module. This option can be given
multiple times.
* use_bdb, bdb_env and bdb_memcache
Apache::DBI::Cache can use BerleleyDB as a shared memory
implementation to maintain statistics for a group of processes
instead of a single process.
"use_bdb" specify whether to use BerkeleyDB or not. If ommitted
Apache::DBI::Cache will try to load and use BerkeleyDB. If that
fails it silently provides per process statistics. If "use_bdb" is
true Apache::DBI::Cache dies if it cannot use BerkeleyDB. If
"use_bdb" is false per process statistics are maintained and
BerkeleyDB is not used.
"bdb_env" specifies a path to a directory where BerkeleyDB can put
it's temporary files. If omitted "/tmp/Apache::DBI::Cache" is
used. The parent directory of this directory must exists and be
writeable.
"bdb_memcache" specifies the size of the shared memory segment
that is allocated by BerkeleyDB. Depending on the number of
handles in your configuration a few kilobytes are enough. If
omitted 20 kB are used.
"bdb_env" and "bdb_memcache" can also be specified by the
"APACHE_DBI_CACHE_ENVPATH" and "APACHE_DBI_CACHE_CACHESIZE"
environment variables.
* debug
set a debug level. Under mod_perl this is almost irrelevant, see
"logger" below.
* logger
here a logger function can be specified. It is called with the
message verbosity level as the first parameter. The remaining
parameters are concatenated to build the actual message.
Currently there are 2 verbosity levels used 1 and 2. 0 is reserved
for real errors. 1 mentions that the module has been initialized.
2 rattle off normal processing messages.
Apache::DBI::Cache provides 2 logger functions. One is controlled
by the "debug" level setting (see above). A message is printed to
STDERR if it's level is equal or greater the current debug level.
The other logger is used when running under mod_perl. It is mainly
controlled by the Apache "LogLevel" setting. Messages at level 0
are printed as "$log->error", level 1 as "$log->info" and level 2
as "$log->debug". For level 2 messages additionally the current
debug level is checked to be greater or equal 2.
* delimiter
Here the internal key delimiter can be changed. It defaults to
"\1". Changing it is necessary only when your DSN, username or
password contain it or to provide more readable debugging
messages.
statistics
returns a reference to the statistics hash. If BerkeleyDB is used it
is tied to BerkeleyDB::Btree.
statistics_as_html
returns a reference to an array of HTML fragments. If mod_perl and
Apache::Status or Apache::Status2 is used the output of this
function is shown under http://HOST/STATUS/URI?DBI_conn.
plugin( 'name', \&mangle, \&setup )
installs a new plugin, see "PLUGINS" below. If a plugin for the
specified database type was already installed it is returned as a
2-element list:
($old_mangle, $old_setup)=
plugin( 'name', \&new_mangle, \&new_setup );
If called with an name only the current plugin is returned:
($old_mangle, $old_setup)=plugin( 'name' );
To delete a plugin call
($old_mangle, $old_setup)=plugin( 'name', undef, undef );
connect_on_init
call this function multiple times with parameters you would pass to
"DBI->connect" before calling "Apache::DBI::Cache::init", i.e. in
your "startup.pl". Then "init" will establish all these connections.
init
This function is called once per child process to initialize
Apache::DBI::Cache. If mod_perl is used this is done automatically
in a PerlChildInitHandler
finish
This function must be called before a process is going to terminate.
Under mod_perl it is automatically called in a PerlChildExitHandler.
As of version 0.08 calling this function is optional.
undef_at_request_cleanup( \$dbh1, \$dbh2, ... )
When an application uses global variables to store handles they
probably won't be reused because a global variable is ..., well
global. This can be fixed by explicitly undefining these handles at
request cleanup or by using this function. It simply collects all
handle references passed in between 2 calls to
"Apache::DBI::Cache::request_cleanup". When
"Apache::DBI::Cache::request_cleanup" is called all these handles
are undefined. The first call to this function during a request
cycle installs "Apache::DBI::Cache::request_cleanup" as
PerlCleanupHandler.
With mod_perl2 this requires the PerlOption "GlobalRequest" to be
set:
PerlOption +GlobalRequest
( run in 1.132 second using v1.01-cache-2.11-cpan-5837b0d9d2c )