| 1 | package MYDan::Node::DBI::Cache; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | MYDan::Node::DBI::Cache - DB interface to MYDan::Node cache data | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use MYDan::Node::DBI::Cache; | ||
| 10 | |||
| 11 | my $db = MYDan::Node::DBI::Cache->new( '/database/file' ); | ||
| 12 | |||
| 13 | $db->select( 'node', name => [ 1, 'foo' ] ); | ||
| 14 | |||
| 15 | =cut | ||
| 16 | use strict; | ||
| 17 | use warnings; | ||
| 18 | |||
| 19 | =head1 METHODS | ||
| 20 | |||
| 21 | See MYDan::Util::SQLiteDB. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | use base qw( MYDan::Util::SQLiteDB ); | ||
| 25 | |||
| 26 | =head1 DATABASE | ||
| 27 | |||
| 28 | A SQLITE db has a I<node> table of I<four> columns: | ||
| 29 | |||
| 30 | name : cluster name | ||
| 31 | attr : table name | ||
| 32 | node : node name | ||
| 33 | info : info associated with node | ||
| 34 | |||
| 35 | =cut | ||
| 36 | our $TABLE = 'node'; | ||
| 37 | |||
| 38 | sub define | ||
| 39 | { | ||
| 40 | name => 'TEXT NOT NULL', | ||
| 41 | attr => 'TEXT NOT NULL', | ||
| 42 | node => 'TEXT NOT NULL', | ||
| 43 | info => 'BLOB', | ||
| 44 | }; | ||
| 45 | |||
| 46 | |||
| 47 | =head3 insert( @record ) | ||
| 48 | |||
| 49 | Insert @record into $table. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | sub insert | ||
| 53 | { | ||
| 54 | my $self = shift; | ||
| 55 | $self->SUPER::insert( $TABLE, @_ ); | ||
| 56 | } | ||
| 57 | |||
| 58 | =head3 select( $column, %query ) | ||
| 59 | |||
| 60 | Select $column from $table. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | sub select | ||
| 64 | { | ||
| 65 | my $self = shift; | ||
| 66 | $self->SUPER::select( $TABLE, @_ ); | ||
| 67 | } | ||
| 68 | |||
| 69 | =head3 delete( %query ) | ||
| 70 | |||
| 71 | Delete records from $table. | ||
| 72 | |||
| 73 | =cut | ||
| 74 | sub delete | ||
| 75 | { | ||
| 76 | my $self = shift; | ||
| 77 | $self->SUPER::delete( $TABLE, @_ ); | ||
| 78 | } | ||
| 79 | |||
| 80 | 1; |