The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Varnish::CLI - An interface to the Varnish CLI

VERSION

Version 0.03

SYNOPSIS

Varnish CLI is a great administration tool, but a bit difficult to script for. This module allows easy script interface to it.

    use Varnish::CLI;
    my $varnish = Varnish::CLI->new( host    => $host,
                                     port    => $port,
                                     timeout => $timeout,
                                     secret  => $secret,
                                );
    $varnish->send( 'url.purge .*' );

The Varnish::CLI can be initialised without any parameters, and will usually work for the default Varnish settings:

    my $varnish = Varnish::CLI->new();

If you have started your Varnish CLI with a secret, you must will have to pass the contents of your secret file, otherwise authentication will fail... Makes sense!! :) Remember - complete contents of the secret file (including a newline if it exists!)

    my $varnish = Varnish::CLI->new( secret => $secret );
    

PROPERTIES

    has host =>        ( is       => 'ro',
                         isa      => 'Str',
                         required => 1,
                         default  => 'localhost' );

    has port =>        ( is       => 'ro',
                         isa      => 'Int',
                         required => 1,
                         default  => 6082 );

    has timeout =>     ( is       => 'rw',
                         isa      => 'Int',
                         required => 1,
                         default  => 1 );

    has t =>           ( is       => 'rw',
                         isa      => 'Net::Telnet',
                         clearer  => 'clear_t' );
                
    has secret =>      ( is       => 'rw',
                         isa      => 'Str' );

    has connected =>   ( is       => 'rw',
                         isa      => 'Int',
                         default  => 0,
                         required => 1 );

    has last_lines =>  ( is       => 'rw',
                         isa      => 'ArrayRef',
                         default  => sub{ [] } );

    has last_status => ( is       => 'rw',
                         isa      => 'Int',
                        );

SUBROUTINES/METHODS

connect

Connect to the Varnish CLI interface

close

Close the connection to the Varnish CLI interface

send

Send a command to the Varnish CLi

AUTHOR

Robin Clarke, <perl at robinclarke.net>

BUGS

Please report any bugs or feature requests to bug-varnish at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Varnish. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Varnish::CLI

You can also look for information at:

ACKNOWLEDGEMENTS

http://www.varnish-cache.org/

LICENSE AND COPYRIGHT

Copyright 2011 Robin Clarke.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.