Re: Fix for PEAR Cache_Container_db.php
| From: | Christian Stocker | Date: | Thu, 07 Nov 2002 21:37:08 +0000 |
| Subject: | Re: Fix for PEAR Cache_Container_db.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10580@lists.php.net to get a copy of this message | ||
Hi Lorenzo
Can you make a unified diff patch file out of this and not sending the
whole code. It makes it much easier to see, what you changed and i don't
have to do copy&paste and fighting with some funny whitespacehandling of
my mailclients :)
Concerning your MDB Container, the problem I have with it, is just that
we need then to make a dependency on MDB and MDB will be installed if
you want PEAR::Cache and this is some kind of not-expecting for everyone
who doesn't use the MDB Container... Are there any possiblities, to make
a dependency just a "suggested additional packages needed" :) I'm sure
someone of you guys thought about that before.
Thanks
chregu
On Thu, 2002-10-31 at 21:04, Lorenzo Alberton wrote:
> 31/10/2002 21.04.46
>
> This fixes a possible error with garbageCollection(), plus
> makes it more portable (does NOT rely on mysql's NOW() function).
>
> Just replace garbageCollection() method in Cache/Container/db.php
> with the following one:
>
> ======================================================
>
> function garbageCollection($maxlifetime)
> {
> $this->flushPreload();
>
> $query = 'DELETE FROM ' . $this->cache_table
> .' WHERE (expires <= ' . time()
> .' AND expires > 0) OR changed <= '. time() -
> $maxlifetime;
>
> $res = $this->db->query($query);
>
> $query = 'SELECT sum(length(cachedata)) as CacheSize FROM '
> . $this->cache_table;
>
> $cachesize = $this->db->GetOne($query);
> //if cache is to big.
> if ($cachesize > $this->highwater)
> {
> //find the lowwater mark.
> $query = 'SELECT length(cachedata) as size, changed FROM '
> . $this->cache_table .' ORDER BY changed DESC';
>
> $res = $this->db->query($query);
> $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 = 'DELETE FROM '
> . $this->cache_table .' WHERE changed<='
> . ($entry['changed'] ? $entry['changed'] : 0);
>
> $res = $this->db->query($query);
> if (DB::isError($res)) {
> return new Cache_Error('DB::query failed: '
> . DB::errorMessage($res), __FILE__, __LINE__);
> }
> }
> }
>
> ======================================================
>
> Regards,
> Lorenzo Alberton
>
>
> P.S. for Sebastian (or another Cache mantainer): could you include
> the "mdb_container" in PEAR::Cache package?
> You can find it at this address:
> http://utenti.lycos.it/pearzone/
> Thank you
>
> ---
> [Quipo ISP - Questa E-mail e' stata controllata dal programma Declude Virus]
> [Quipo ISP - This E-mail was scanned for viruses by Declude Virus]
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php