Lines 672-680
sub AUTOLOAD
Link Here
|
672 |
|
672 |
|
673 |
$Zconn = C4::Context->Zconn |
673 |
$Zconn = C4::Context->Zconn |
674 |
|
674 |
|
675 |
Returns a connection to the Zebra database for the current |
675 |
Returns a connection to the Zebra database |
676 |
context. If no connection has yet been made, this method |
|
|
677 |
creates one and connects. |
678 |
|
676 |
|
679 |
C<$self> |
677 |
C<$self> |
680 |
|
678 |
|
Lines 689-713
C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
Link Here
|
689 |
|
687 |
|
690 |
sub Zconn { |
688 |
sub Zconn { |
691 |
my ($self, $server, $async, $auth, $piggyback, $syntax) = @_; |
689 |
my ($self, $server, $async, $auth, $piggyback, $syntax) = @_; |
692 |
#TODO: We actually just ignore the auth and syntax parameter |
690 |
my $connection = _new_Zconn( $server, $async, $piggyback ); |
693 |
#It also looks like we are not passing auth, piggyback, syntax anywhere |
691 |
return $connection; |
694 |
|
|
|
695 |
my $cache_key = join ('::', (map { $_ // '' } ($server, $async, $auth, $piggyback, $syntax))); |
696 |
if ( defined($context->{"Zconn"}->{$cache_key}) && (0 == $context->{"Zconn"}->{$cache_key}->errcode()) ) { |
697 |
return $context->{"Zconn"}->{$cache_key}; |
698 |
# No connection object or it died. Create one. |
699 |
}else { |
700 |
# release resources if we're closing a connection and making a new one |
701 |
# FIXME: this needs to be smarter -- an error due to a malformed query or |
702 |
# a missing index does not necessarily require us to close the connection |
703 |
# and make a new one, particularly for a batch job. However, at |
704 |
# first glance it does not look like there's a way to easily check |
705 |
# the basic health of a ZOOM::Connection |
706 |
$context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key}); |
707 |
|
708 |
$context->{"Zconn"}->{$cache_key} = &_new_Zconn( $server, $async, $piggyback ); |
709 |
return $context->{"Zconn"}->{$cache_key}; |
710 |
} |
711 |
} |
692 |
} |
712 |
|
693 |
|
713 |
=head2 _new_Zconn |
694 |
=head2 _new_Zconn |
714 |
- |
|
|