# we don't want DESTROY to fallback into AUTOLOAD
sub DESTROY {}
+
+### Deal with common, general case, Redis commands
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
$self->__send_command($command, @_);
- if ( $command eq 'quit' ) {
- close( $sock ) || confess("Can't close socket: $!");
- return 1;
- }
-
my $result = <$sock> || confess("Can't read socket: $!");
my $type = substr($result,0,1);
$result = substr($result,1,-2);
}
+### Commands with extra logic
+
+sub quit {
+ my ($self) = @_;
+
+ $self->__send_command('QUIT');
+
+ close(delete $self->{sock}) || confess("Can't close socket: $!");
+ return 1;
+}
+
+
### Socket operations
sub __send_command {