experimental caching

This commit is contained in:
Patrick Donelan 2009-10-15 09:48:40 +11:00
parent b9bff5a2f6
commit cde333e931
5 changed files with 29 additions and 15 deletions

View file

@ -1,23 +1,23 @@
use Plack::Builder;
use lib '/data/WebGUI/lib';
use WebGUI;
WebGUI->init( root => '/data/WebGUI', config => 'dev.localhost.localdomain.conf' );
builder {
# Populate $env from site.conf
add 'Plack::Middleware::WebGUI',
root => '/data/WebGUI',
config => 'dev.localhost.localdomain.conf';
# Handle /extras via Plack::Middleware::Static
# (or Plack::Middleware::WebGUI could do this for us by looking up extrasPath and extrasURL in site.conf)
add 'Plack::Middleware::Static',
enable 'Plack::Middleware::Static',
path => qr{^/extras/},
root => '/data/WebGUI/www';
# Handle /uploads via Plack::Middleware::WGAccess (including .wgaccess)
# (or Plack::Middleware::WebGUI could do this for us by looking up uploadsPath and uploadsURL in site.conf)
add 'Plack::Middleware::WGAccess',
#enable 'Plack::Middleware::WGAccess',
# path => qr{^/uploads/},
# root => '/data/domains/dev.localhost.localdomain/public';
enable 'Plack::Middleware::Static',
path => qr{^/uploads/},
root => '/data/domains/dev.localhost.localdomain/public';

View file

@ -13,8 +13,6 @@ Plack::Middleware::WebGUI
Plack Middleware that populates $env
In the future we might want to read the site.conf here and then cache it
=cut
sub call {

View file

@ -162,15 +162,17 @@ The Apache2::RequestRec object passed in by Apache's mod_perl.
sub handler {
my $request = shift; # either apache request object or PSGI env hash
my $server;
my ($server, $config);
if ($request->isa('WebGUI::Session::Plack')) {
$server = $request->server;
$config = WebGUI->config;
} else {
$request = Apache2::Request->new($request);
$server = Apache2::ServerUtil->server; #instantiate the server api
my $configFile = shift || $request->dir_config('WebguiConfig'); #either we got a config file, or we'll build it from the request object's settings
$config = WebGUI::Config->new($server->dir_config('WebguiRoot'), $configFile); #instantiate the config object
}
my $configFile = shift || $request->dir_config('WebguiConfig'); #either we got a config file, or we'll build it from the request object's settings
my $config = WebGUI::Config->new($server->dir_config('WebguiRoot'), $configFile); #instantiate the config object
my $error = "";
my $matchUri = $request->uri;
my $gateway = $config->get("gateway");
@ -231,5 +233,19 @@ sub handle_psgi {
return $plack->finalize;
}
# Experimental speed boost
my ($root, $config_file, $config);
sub init {
my $class = shift;
my %opts = @_;
$root = $opts{root};
$config_file = $opts{config};
$config = WebGUI::Config->new($root, $config_file);
warn 'INIT';
}
sub config { $config }
sub root { $root }
sub config_file { $config_file }
1;

View file

@ -460,7 +460,7 @@ sub open {
my $configFile = shift;
my $request = shift;
my $server = shift;
my $config = WebGUI::Config->new($webguiRoot,$configFile);
my $config = WebGUI->config || WebGUI::Config->new($webguiRoot,$configFile);
my $self = {_config=>$config, _server=>$server};
bless $self , $class;

View file

@ -160,8 +160,8 @@ sub dir_config {
my ( $self, $c ) = @_;
# Translate the legacy WebguiRoot and WebguiConfig PerlSetVar's into known values
return $self->{env}->{'wg.WEBGUI_ROOT'} if $c eq 'WebguiRoot';
return $self->{env}->{'wg.WEBGUI_CONFIG'} if $c eq 'WebguiConfig';
return WebGUI->root if $c eq 'WebguiRoot';
return WebGUI->config_file if $c eq 'WebguiConfig';
# Otherwise, we might want to provide some sort of support (which Apache is still around)
return $self->{env}->{"wg.DIR_CONFIG.$c"};