Search::InvertedIndex::DB::Pg - A Postgres backend for Search::InvertedIndex.
use Search::InvertedIndex; use Search::InvertedIndex::DB::Pg; my $db = Search::InvertedIndex::DB::Pg->new( -db_name => "testdb", -hostname => "test.example.com", -port => 5432, -username => "testuser", -password => "testpass", -table_name => "siindex", -lock_mode => "EX", ); my $map = Search::InvertedIndex->new( -database => $db );
An interface allowing Search::InvertedIndex to store and retrieve data from a PostgreSQL database. All the data is stored in a single table, which will be created automatically if it does not exist when new is called.
new
my $db = Search::InvertedIndex::DB::Pg->new( -db_name => "testdb", -hostname => "test.example.com", -port => 5432, -username => "testuser", -password => "testpass", -table_name => "siindex", -lock_mode => "EX", );
-db_name and -table_name are mandatory. -lock_mode defaults to EX. -port is optional and defaults to not being specified..
-db_name
-table_name
-lock_mode
EX
-port is optional
$db->open;
Opens the database in the mode specified when new was called. Croaks on error, returns true otherwise. Trying to open a nonexistent database/table combination in SH mode is considered to be an error. Opening an already-open database/table combination isn't.
SH
$db->lock( -lock_mode => "EX" );
The -lock_mode parameter is required; allowed values are EX, SH and UN. Returns true on success; croaks on error.
UN
my $opened = $db->status( "-open" ); my $lock_mode = $db->status( "-lock_mode" );
Allowed requests are -open and -lock_mode. -lock_mode can only be called on an open database. -lock is a synonym for -lock_mode. Croaks if sent an invalid request, or on error.
-open
-lock
$db->put( -key => "foo", -value => "bar" );
Both parameters are mandatory. Any others will be silently ignored. Returns true on success and false on error.
my $value = $db->get( -key => "foo" );
Croaks if no -key supplied.
-key
$db->delete( -key => "foo" );
$db->close;
$db->clear;
Clears out all indexing data.
Kate L Pugh <kake@earth.li>, based on Search::InvertedIndex::DB::Mysql by Michael Cramer and Search::InvertedIndex::DB::DB_File_SplitHash by Benjamin Franz.
Copyright (C) 2003-4 Kake Pugh. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module based on work by Michael Cramer and Benjamin Franz. Patch from Cees Hek.
Search::InvertedIndex
To install Search::InvertedIndex::DB::Pg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::InvertedIndex::DB::Pg
CPAN shell
perl -MCPAN -e shell install Search::InvertedIndex::DB::Pg
For more information on module installation, please visit the detailed CPAN module installation guide.