added database cache cleaner

This commit is contained in:
JT Smith 2006-04-27 05:29:48 +00:00
parent cb29744bce
commit 44e03d36e5
6 changed files with 148 additions and 3 deletions

View file

@ -108,6 +108,22 @@ sub get {
#-------------------------------------------------------------------
=head2 getNamespaceSize ( )
Returns the size (in bytes) of the current cache under this namespace. Consequently it also cleans up expired cache items.
=cut
sub getNamespaceSize {
my $self = shift;
my $expiresModifier = shift || 0;
$self->session->db->write("delete from cache where expires < ?",[time()+$expiresModifier]);
my ($size) = $self->session->db->quickArray("select sum(size) from cache where namepsace=?",[$self->{_namespace}]);
return $size;
}
#-------------------------------------------------------------------
=head2 new ( session, key [, namespace ] )
Constructor.