DBD-PgLite
view release on metacpan or search on metacpan
lib/DBD/PgLite.pm view on Meta::CPAN
argnum => 3,
func => sub { _setval(@_) }
},
# Misc Functions
# http://www.postgresql.org/docs/current/static/functions-misc.html
# Most of these are omitted.
{
name => 'current_user',
argnum => 0,
func => sub { (getpwuid $>)[0] }
},
{
name => 'session_user',
argnum => 0,
func => sub { (getpwuid $>)[0] }
},
{
name => 'user',
argnum => 0,
func => sub { (getpwuid $>)[0] }
},
);
# Transforms a stored procedure into a coderef
sub _sp_func {
my $dbh = shift;
my $name = shift;
my $sql = shift;
my $ret = sub {
lib/DBD/PgLite/MirrorPgToSQLite.pm view on Meta::CPAN
sub cached_schema {
my ($sn,$tn,$creat,$cnt,%opt) = @_;
my $database = $opt{pg_dbh}->{mbl_dbh}
? $opt{pg_dbh}->{mbl_dbh}->[0]->{Name}
: $opt{pg_dbh}->{Name};
unless (-d $opt{cachedir}) {
mkdir $opt{cachedir};
chmod 0777, $opt{cachedir};
}
my $uid = (getpwuid($>))[0] || $>;
mkdir "$opt{cachedir}/$uid" unless -d "$opt{cachedir}/$uid";
my $fn = "$opt{cachedir}/$uid/$database.$sn.$tn";
if ($cnt) {
Storable::store [$creat,$cnt], $fn;
} elsif (-f $fn && time-(stat $fn)[9]<7*24*60*60) {
my $ret = Storable::retrieve $fn || [];
return @$ret;
} else {
return ();
}
( run in 0.268 second using v1.01-cache-2.11-cpan-8d75d55dd25 )