NAME

Dezi::Bot::Handler::FileCacher - web crawler handler that caches files

SYNOPSIS

use Dezi::Bot::Handler::FileCacher;
my $handler = Dezi::Bot::Handler::FileCacher->new(
   dsn      => "DBI:mysql:database=$database;host=$hostname;port=$port",
   username => 'myuser',
   password => 'mysecret',
   root_dir => '/path/to/site/mirror',
);
$handler->handle( $swish_prog_doc );

DESCRIPTION

The Dezi::Bot::Handler::FileCacher writes each doc to the filesystem, managing its progress and status via DBI.

METHODS

new( config )

Returns a new Dezi::Bot::Handler::FileCacher object. config must have:

dsn

Passed to DBI->connect.

username

Passed to DBI->connect.

password

Passed to DBI->connect.

table_name

The table_name value will be used to insert rows. Defaults to dezi_file_cache.

queue_name

The queue_name value will be inserted for each row in the database.

quote

The quote value will be used to quote column names on insert. Defaults to false.

quote_char

The quote_char value will be used when quote is true. Defaults to backtick.

root_dir

Base path for writing cached files.

init

Internal method to initialize object.

handle( doc )

Metadata from doc is stored via DBI and doc is written to disk.

write_record( record )

Write the key/value pairs of record to the database represented by dsn. record is metadata about the cached file. Timestamps are automatically added to record by write_record().

Returns the id (primary key) of the new record.

schema

Callable as a function or class method. Returns string suitable for initializing a dezi_filecache SQL table.

Example:

perl -e 'use Dezi::Bot::Handler::FileCacher; print Dezi::Bot::Handler::FileCacher::schema' |\
 sqlite3 dezi.index/bot.db

AUTHOR

Peter Karman, <karman at cpan.org>

BUGS

Please report any bugs or feature requests to bug-dezi-bot at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-Bot. 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 Dezi::Bot

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2013 Peter Karman.

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.