cvs: pear /Cache/Container db.php

From: Date: Fri, 08 Nov 2002 15:24:50 +0000
Subject: cvs: pear /Cache/Container db.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7321@lists.php.net to get a copy of this message
chregu Fri Nov 8 10:24:50 2002 EDT Modified files: /pear/Cache/Container db.php Log: fixed garbage collection in db.php (by Lorenzo) Index: pear/Cache/Container/db.php diff -u pear/Cache/Container/db.php:1.2 pear/Cache/Container/db.php:1.3 --- pear/Cache/Container/db.php:1.2 Fri Jul 12 13:30:57 2002 +++ pear/Cache/Container/db.php Fri Nov 8 10:24:49 2002 @@ -17,7 +17,7 @@ // | Chuck Hagenbuch <chuck@horde.org> | // +----------------------------------------------------------------------+ // -// $Id: db.php,v 1.2 2002/07/12 17:30:57 sebastian Exp $ +// $Id: db.php,v 1.3 2002/11/08 15:24:49 chregu Exp $ require_once 'DB.php'; require_once 'Cache/Container.php'; @@ -52,7 +52,7 @@ * ) * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> -* @version $Id: db.php,v 1.2 2002/07/12 17:30:57 sebastian Exp $ +* @version $Id: db.php,v 1.3 2002/11/08 15:24:49 chregu Exp $ * @package Cache */ class Cache_Container_db extends Cache_Container { @@ -217,10 +217,10 @@ { $this->flushPreload(); - $query = sprintf('DELETE FROM %s WHERE (expires <= %d AND expires > 0) OR changed <= (NOW() - %d)', + $query = sprintf('DELETE FROM %s WHERE (expires <= %d AND expires > 0) OR changed <= %d', $this->cache_table, time(), - $maxlifetime + time() - $maxlifetime ); $res = $this->db->query($query); @@ -237,14 +237,15 @@ $this->cache_table ); $res = $this->db->query($query); - $keep_size=0; - while ($keep_size < $this->lowwater && $entry = $res->FetchRow(DB_FETCHMOD_ASSOC) ) - { - $keep_size += $entry[size]; + $numrows = $this->db->numRows($res); + $keep_size = 0; + while ($keep_size < $this->lowwater && $numrows--) { + $entry = $res->fetchRow(DB_FETCHMODE_ASSOC); + $keep_size += $entry['size']; } //delete all entries, which were changed before the "lowwwater mark" - $query = sprintf('delete from %s where changed <= '.$entry[changed], + $query = sprintf('delete from %s where changed <= '.($entry['changed'] ? $entry['changed'] : 0), $this->cache_table ); $res = $this->db->query($query); @@ -256,4 +257,4 @@ } } -?> \ No newline at end of file +?>

« previous php.pear.cvs (#7321) next »