Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29383 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87817 invoked by uid 1010); 9 May 2007 17:47:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87802 invoked from network); 9 May 2007 17:47:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2007 17:47:23 -0000 X-Host-Fingerprint: 88.67.25.66 dslb-088-067-025-066.pools.arcor-ip.net Received: from [88.67.25.66] ([88.67.25.66:6128] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/91-60325-92902464 for ; Wed, 09 May 2007 13:47:23 -0400 Message-ID: <4C.91.60325.92902464@pb1.pair.com> To: internals@lists.php.net Date: Wed, 09 May 2007 19:47:20 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 References: <0E.B4.18102.F9DB9264@pb1.pair.com> <463F9FD0.3030009@zend.com> <463FA701.5030707@pooteeweet.org> <46406F89.7030000@zend.com> <4640749E.20005@zend.com> <46407819.40808@zend.com> <46407B27.1010705@pooteeweet.org> <46409661.4000106@zend.com> In-Reply-To: <46409661.4000106@zend.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 88.67.25.66 Subject: Re: [PHP-DEV] serialize and cache handling From: phpinternals@thunder-2000.com (Mathias Bank) > If his cache had no locking before, what changed? Well, I have been using several cache classes. A good cache class is the pear cache light. This cache is serializing your data and write this data to a file - of course with file locking. I could imagine, that a improved serialize-function could work like this: $fp = @fopen($filename, "wb"); if ($fp) { @flock($fp, LOCK_EX); serialize($data,$fp); @flock($fp, LOCK_UN); @fclose($fp); } This method makes it possible to decide, if you want to use a locking function or not. The same technique could be applied to imagepng (and others): instead of writing imagepng($img,"/path/to/file"); it would be better to write $fp = @fopen($filename, "wb"); if ($fp) { @flock($fp, LOCK_EX); imagepng($img,$fp); @flock($fp, LOCK_UN); @fclose($fp); } This way, you can decide, if you want to use locking functions or not. I think, this could be a big improvement (until now you have to use imagepng in combination with ob_start / ob_get_contents / ob_end_clean to cache images in a secure way). Mathias