bug fixes
This commit is contained in:
parent
26c3bdac70
commit
d16a220628
4 changed files with 104 additions and 10 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
89
t/Cache.t
89
t/Cache.t
|
|
@ -29,11 +29,11 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 10; # Increment this number for each test you create
|
||||
plan tests => 11; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
my $cache = WebGUI::Cache->new($session);
|
||||
my $cache = WebGUI::Cache->new($session, 1);
|
||||
isa_ok($cache, 'WebGUI::Cache');
|
||||
is($cache->parseKey("andy"), $session->config->getFilename.":andy", "parseKey single key");
|
||||
is($cache->parseKey(["andy","red"]), $session->config->getFilename.":andy:red", "parseKey composite key");
|
||||
|
|
@ -50,6 +50,91 @@ $cache->flush;
|
|||
is(eval{$cache->get(["andy", "dufresne"])}, undef, 'flush');
|
||||
$cache->setByHttp("http://www.google.com/");
|
||||
cmp_ok($cache->get("http://www.google.com/"), 'ne', '', 'setByHttp');
|
||||
my $longValue ='abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
|
||||
';
|
||||
$cache->set("really-long-value",$longValue);
|
||||
is($cache->get("really-long-value"), $longValue, "set/get really long value");
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue