bug fixes

This commit is contained in:
JT Smith 2009-09-28 17:36:10 -05:00
parent 26c3bdac70
commit d16a220628
4 changed files with 104 additions and 10 deletions

View file

@ -1778,17 +1778,15 @@ sub new {
}
my $properties = eval{$session->cache->get(["asset",$assetId,$revisionDate])};
if (exists $properties->{assetId}) {
# got properties from cache
}
else {
unless (exists $properties->{assetId}) {
$properties = WebGUI::Asset->assetDbProperties($session, $assetId, $class, $revisionDate);
unless (exists $properties->{assetId}) {
$session->errorHandler->error("Asset $assetId $class $revisionDate is missing properties. Consult your database tables for corruption. ");
return undef;
}
eval{$session->cache->set(["asset",$assetId,$revisionDate], $properties, 60*60*24)};
eval{ $session->cache->set(["asset",$assetId,$revisionDate], $properties, 60*60*24) };
}
if (defined $properties) {
my $object = { _session=>$session, _properties => $properties };
bless $object, $class;

View file

@ -23,7 +23,11 @@ use Memcached::libmemcached;
use Storable ();
use WebGUI::Exception;
use Params::Validate qw(:all);
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
Params::Validate::validation_options( on_fail => sub {
my $error = shift;
warn "Error in Cache params: ".$error;
WebGUI::Error::InvalidParam->throw( error => $error );
} );
@ -91,6 +95,13 @@ sub delete {
error => "Cannot connect to memcached server."
);
}
elsif ($memcached->errstr eq 'NOT FOUND' ) {
$log->debug("The cache key $key has no value.");
WebGUI::Error::ObjectNotFound->throw(
error => "The cache key $key has no value.",
id => $key,
);
}
elsif ($memcached->errstr eq 'NO SERVERS DEFINED') {
$log->warn("No memcached servers specified in config file.");
WebGUI::Error->throw(
@ -394,7 +405,7 @@ A time in seconds for the cache to exist. When you override default it to 60 sec
sub set {
my $self = shift;
my $debug = $self->withDebug;
my ($name, $value, $ttl) = ($debug) ? validate_pos(@_, { type => SCALAR | ARRAYREF }, { type => SCALAR }, { type => SCALAR | UNDEF, optional => 1 }) : @_;
my ($name, $value, $ttl) = ($debug) ? validate_pos(@_, { type => SCALAR | ARRAYREF }, { type => SCALAR | ARRAYREF | HASHREF }, { type => SCALAR | UNDEF, optional => 1 }) : @_;
$ttl ||= 60;
my $key = $self->parseKey($name);
if ($debug) {

View file

@ -202,7 +202,7 @@ sub new {
}
else {
$self->{_var}{nextCacheFlush} = $time + $session->config->get("hotSessionFlushToDb");
$session->cache->set(['session',$sessionId], $self->{_var}, $timeout);
eval{$session->cache->set(['session',$sessionId], $self->{_var}, $timeout)};
}
$self->session->{_sessionId} = $self->{_var}{sessionId};
return $self;