initial CHI implementation
This commit is contained in:
parent
d46f77bf2e
commit
5cdde20633
1 changed files with 37 additions and 12 deletions
|
|
@ -15,7 +15,10 @@ package WebGUI::Session;
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use WebGUI::Cache;
|
use 5.010;
|
||||||
|
|
||||||
|
use CHI;
|
||||||
|
use File::Temp;
|
||||||
use WebGUI::Config;
|
use WebGUI::Config;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
|
|
@ -117,17 +120,39 @@ Returns a WebGUI::Cache object, which is connected to the WebGUI memcached serve
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub cache {
|
sub cache {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
unless (exists $self->{_cache}) {
|
unless (exists $self->{_cache}) {
|
||||||
my $cache = WebGUI::Cache->new($self);
|
my $cacheConf = $self->config->get('cache');
|
||||||
if (defined $cache) {
|
|
||||||
$self->{_cache} = $cache;
|
# Default values
|
||||||
}
|
my $resolveConf = sub {
|
||||||
else {
|
my ($config) = @_;
|
||||||
$self->log->fatal("Couldn't connect to WebGUI memcached server, and can't continue without it.");
|
given ( $config->{driver} ) {
|
||||||
}
|
when ( /DBI/ ) {
|
||||||
}
|
$config->{ dbh } = $self->db->dbh;
|
||||||
return $self->{_cache};
|
continue;
|
||||||
|
}
|
||||||
|
when ( /File|FastMmap|BerkeleyDB/ ) {
|
||||||
|
$config->{ root_dir } ||= tempdir();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
when ( /FastMmap/ ) {
|
||||||
|
#$config->{ cache_size } = '64m';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$config->{namespace} ||= $self->config->get('sitename')->[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
$resolveConf->( $cacheConf );
|
||||||
|
if ( $cacheConf->{l1_cache} ) {
|
||||||
|
$resolveConf->( $cacheConf->{l1_cache} );
|
||||||
|
}
|
||||||
|
|
||||||
|
my $cache = CHI->new( %{$cacheConf} );
|
||||||
|
$self->{_cache} = $cache;
|
||||||
|
}
|
||||||
|
return $self->{_cache};
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue