fixed a couple bugs and added size aware file cache

This commit is contained in:
JT Smith 2005-07-07 19:53:19 +00:00
parent cb2bf8dcaf
commit d72dd21826
9 changed files with 87 additions and 12 deletions

View file

@ -106,19 +106,20 @@ sub getIndexerParams {
sql => "select Article.assetId,
Article.linkTitle,
Article.linkURL,
asset.title,
asset.menuTitle,
asset.url,
assetData.title,
assetData.menuTitle,
assetData.url,
asset.className,
asset.ownerUserId,
asset.groupIdView,
asset.synopsis,
assetData.ownerUserId,
assetData.groupIdView,
assetData.synopsis,
wobject.description
from asset, Article
left join wobject on wobject.assetId = asset.assetId
left join assetData asset.assetId=assetData.assetId
where asset.assetId = Article.assetId
and asset.startDate < $now
and asset.endDate > $now",
and assetData.startDate < $now
and assetData.endDate > $now",
fieldsToIndex => ["linkTitle" ,"linkURL","title","menuTitle","url","synopsis","description" ],
contentType => 'content',
url => 'WebGUI::URL::gateway($data{url})',

View file

@ -66,7 +66,7 @@ These methods are available from this package:
sub _recurseCrumbTrail {
my ($sth, %data, $output);
tie %data, 'Tie::CPHash';
%data = WebGUI::SQL->quickHash("select assetId,parentId,menuTitle,url from asset where assetId=".quote($_[0]));
%data = WebGUI::SQL->quickHash("select asset.assetId,asset.parentId,assetData.menuTitle,asset.url from asset left join assetData on asset.assetId=assetData.assetId where asset.assetId=".quote($_[0])." group by assetData.assetId order by assetData.revisionDate desc");
if ($data{assetId}) {
$output .= _recurseCrumbTrail($data{parentId});
}

View file

@ -14,7 +14,7 @@ package WebGUI::Cache::FileCache;
=cut
use Cache::FileCache;
use Cache::SizeAwareFileCache;
use HTTP::Headers;
use HTTP::Request;
@ -136,7 +136,7 @@ sub new {
auto_purge_on_set=>1
);
$options{cache_root} = $session{config}{fileCacheRoot} if ($session{config}{fileCacheRoot});
$cache = new Cache::FileCache(\%options);
$cache = new Cache::SizeAwareFileCache(\%options);
bless {_cache => $cache, _key => $key}, $class;
}
@ -197,6 +197,25 @@ sub setByHTTP {
return $response->content;
}
#-------------------------------------------------------------------
=head2 shrink ( [ size ] )
Reduces the cache down to a specific size to conserve filesystem space.
=head3 size
A size to shrink the cache to in bytes. Defaults to the fileCacheSizeLimit variable in the config file.
=cut
sub shrink {
my $self = shift;
my $size = shift || $session{config}{fileCacheSizeLimit} || 10000000;
$self->{_cache}->limit_size($size);
}
#-------------------------------------------------------------------
=head2 stats ( )