my @c;
+ my $timestamp =
+ exists $h->{timestamp} ? $h->{timestamp} :
+ exists $h->{start} ? $h->{start} :
+ warn "no timestamp partitioning on $table";
+
+ my $create_table;
+ if ( $timestamp ) {
+ $timestamp =~ s/^(\d{4})-(\d{2})-(\d{2}).*$/$1_$2_$3/;
+ my $part = $table . '_' . $timestamp;
+ $create_table = qq{
+ create table $part () inherits ($table) ;
+ };
+ $table = $part;
+ warn "# using partition $table";
+ }
+
if ( my $cols = $self->redis->get("pg.$table") ) {
@c = split(/\s+/,$cols);
} else {
my $sth = $self->dbh->prepare( "select * from $table limit 1" );
- $sth->execute;
+ eval { $sth->execute; };
+ if ( $@ ) {
+ warn "ERROR $@\n# try $create_table\n";
+ $self->dbh->do( $create_table );
+ $sth->execute;
+ }
+
@c = @{ $sth->{NAME_lc} };
$self->redis->set( "pg.$table" => join(' ',@c) );
$self->redis->expire( "pg.$table" => 15 * 60 ); # refresh every 15 min
ip => '127.0.0.1',
username => 'nobody',
rtt => 0.042,
+timestamp => '2011-12-05 01:01:01',
}), 'ping';
diag dump($r);
h => {
foo => 1,
bar => 2,
-}
+},
+start => '2011-12-05 01:01:01',
}), 'ping';
ok( my $r = $o->redis->get( 'table.cpe_Davolink.nobody' ), 'redis' );