Section: User Contributed Perl Documentation (3pm)
use LWP::ConnCache; my $cache = LWP::ConnCache->new; $cache->deposit($type, $key, $sock); $sock = $cache->withdraw($type, $key);
"LWP::ConnCache"class is the standard connection cache manager for LWP::UserAgent.
The following basic methods are provided:
"LWP::ConnCache"object. The only option currently accepted is 'total_capacity'. If specified it initialize the total_capacity option. It defaults to the value 1.:
0, then all connections are immediately dropped. If set to
"undef", then there is no limit.:
$typewill typically be a short string like ``http or ``ftp.:
$checkerargument is a subroutine that is called for each connection. If the routine returns a TRUE value then the connection is dropped. The routine is called with ($conn,
$deposit_time) as arguments.
$checkerargument is absent (or
"undef") all cached connections are dropped. If the
$checkeris a number then all connections untouched that the given number of seconds or more are dropped. If
$checkeris a string then all connections of the given type are dropped. The
$reasonargument is passed on to the dropped() method.
The following methods are called by low-level protocol modules to try to save away connections and to get them back.
$type/$key might added.:
$type/$key is found, then
"undef"is returned. There is not guarantee that a deposited connection can be withdrawn, as the cache manger is free to drop connections at any time.:
The following methods are called internally. Subclasses might want to override them.
$LWP::ConnCache::DEBUGvariable is set and nothing more.:
"LWP::ConnCache"and perhaps override the deposit(), enforce_limits() and dropping() methods. The object itself is a hash. Keys prefixed with
"cc_"are reserved for the base class.
Copyright 2001 Gisle Aas.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Tutoriais de Tecnologia Web