All pastes #2092381 Raw Edit

Untitled

public text v1 · immutable
#2092381 ·published 2011-10-22 00:42 UTC
rendered paste body
my %prefixes = memcached_load_prefixes();

sub memcached_load_prefixes {
        #print Dumper  $memd->get('dxw.pl.prefixes');
        #print "xxxxx";
        my %data = $memd->get('dxw.pl.prefixes') // ();
        #print "dump is: "; print Dumper (\%data);
        if ( keys( %data ) < 2 ) {

                connect_pg();
                if ( $debug == 1)  { print "&memcached_load_prefixes: loading dxw.pl.prefixes from db\n"; }

                my $query = "SELECT prefix AS main_prefix, pfx AS prefix  FROM dxcc_dat dxcc INNER JOIN dxcc_pfx pfx ON pfx.id_dxcc_pfx = dxcc.id order by main_prefix desc LIMIT 20;";
                my $sth = $dbh->prepare(qq{ $query });
                $sth->execute();

                while ( my $line = $sth->fetchrow_hashref ) {
                #print "$line->{main_prefix} -> $line->{prefix}\n";
                        push( @{ $data{ $line->{main_prefix} } }, $line->{prefix} );
                        #push( @{ $data{ $line{main_prefix} } }, $line{prefix} );
                }
        }
print Dumper (\%data);

        #$memd->set('dxw.pl.prefixes', $data, 30);
        return (%data);
}