SWISH::API::Stat - reconnect to a SWISH::API handle if index file changes


  use SWISH::API::Stat;
  my $swish = SWISH::API::Stat->new(
                    log             => $filehandle, 
                    indexes         => [ 'path/to/index' ],
                    paranoia_level  => 1
  # use just like $swish handle in SWISH::API


SWISH::API::Stat will detect if the Swish-e index(es) to which you are connected have been modified and will automatically flush the stale handle and create a new one.

SWISH::API::Stat is most useful in long-running processes where the underlying index might be merged, renamed or replaced, as in a mod_perl setup.


SWISH::API::Stat is a subclass of SWISH::API::More. See that module's documentation.


Create a new object.

In addition the values supported by SWISH::API::More new(), the following key/value pairs are supported:

paranoia_level( 0|1|2|3|4 )

Sets the level at which an index file will be stat()'d to find out if it has changed. The default is 1 which means that every time you access $swish the index will be stat()'d. This is most useful for when you call new_search_object(), since the time lapse between one search object and the next is usually small compared to the lifetime of a long-running process.

It's usually safe to just stay with the default. At most you'll see one query go awry, if by some chance an index changes in the middle of a query (between the time you call new_search_object() and when it is destroyed). If your indexes change often enough that too many requests are failing due to stale filehandles, you can bump the paranoia_level up to 2, which will stat() the index whenever a Search object is execute()'d. If your paranoia level is higher than that, you should be helping the author work on Swish-e version 3, which will have stable incremental indexing and avoid the stale filehandle issue altogether.

paranoia( \%class_to_level )

Get/set the mapping of class names to paranoia_levels. If you really need this, read the source.


SWISH::API, SWISH::API::More, Path::Class::File::Stat


Peter Karman, <>

Thanks to Atomic Learning for supporting some of the development of this module.


Copyright (C) 2006 by Peter Karman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.