Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85309 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72113 invoked from network); 20 Mar 2015 17:23:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 17:23:21 -0000 Authentication-Results: pb1.pair.com header.from=ericsten@microsoft.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ericsten@microsoft.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain microsoft.com designates 157.56.111.139 as permitted sender) X-PHP-List-Original-Sender: ericsten@microsoft.com X-Host-Fingerprint: 157.56.111.139 mail-bn1bon0139.outbound.protection.outlook.com Received: from [157.56.111.139] ([157.56.111.139:29424] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/80-64120-2765C055 for ; Fri, 20 Mar 2015 12:18:43 -0500 Received: from BN1PR03MB108.namprd03.prod.outlook.com (10.255.201.26) by BN1PR03MB087.namprd03.prod.outlook.com (10.255.225.159) with Microsoft SMTP Server (TLS) id 15.1.112.19; Fri, 20 Mar 2015 17:18:39 +0000 Received: from BN1PR03MB105.namprd03.prod.outlook.com (10.255.201.11) by BN1PR03MB108.namprd03.prod.outlook.com (10.255.201.26) with Microsoft SMTP Server (TLS) id 15.1.112.19; Fri, 20 Mar 2015 17:18:37 +0000 Received: from BN1PR03MB105.namprd03.prod.outlook.com ([169.254.8.141]) by BN1PR03MB105.namprd03.prod.outlook.com ([169.254.8.141]) with mapi id 15.01.0112.000; Fri, 20 Mar 2015 17:18:37 +0000 To: Stanislav Malyshev , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [Q] Does PHP have a negative cache for file stat operations? Thread-Index: AdBigl6xcms3XbkhTLCo3UkCn4Fa6gAUpveAABbhOHA= Date: Fri, 20 Mar 2015 17:18:37 +0000 Message-ID: References: <550BBA87.6070307@gmail.com> In-Reply-To: <550BBA87.6070307@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2001:4898:80e8:ee31::3] authentication-results: gmail.com; dkim=none (message not signed) header.d=none; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB108;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB087; x-microsoft-antispam-prvs: x-forefront-antispam-report: BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(51704005)(74316001)(19580405001)(19580395003)(2900100001)(46102003)(2950100001)(2501003)(2656002)(87936001)(33656002)(76176999)(50986999)(102836002)(86362001)(40100003)(76576001)(77156002)(62966003)(86612001)(54356999)(122556002)(92566002)(107886001)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB108;H:BN1PR03MB105.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:BN1PR03MB108;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB108; x-forefront-prvs: 05214FD68E Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Mar 2015 17:18:37.8358 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR03MB108 X-OriginatorOrg: microsoft.onmicrosoft.com Subject: RE: [PHP-DEV] [Q] Does PHP have a negative cache for file stat operations? From: ericsten@microsoft.com (Eric Stenson) From: Stanislav Malyshev [mailto:smalyshev@gmail.com]=20 > > Does the PHP stat cache include negative cache entries? If not, why=20 > > not? > > Negative cache is tricky. Most frequent patterns look like this: >=20 > 1. if(file_exists("blah")) { do stuff } >=20 > 2. if(!file_exists("blah")) { throw new Exception("no blah!"); } do stuff >=20 > 3. if(!file_exists("blah")) { create("blah"); } do stuff >=20 > Caching negative even short term would subtly break case 3, in that it > would force creation of the file every time, thus killing any benefit > from any caching (usually file creation is much more expensive process). Yes, and that was my biggest worry about implementing a negative cache. I'd have to hook all the ways a file could be created in order to correctly flush entries in the negative cache. And, in the case of a site that doesn= 't pathologically try to hit non-existent files, the overhead of a negative cache is wasted cycles. > Long term caching would also be big trouble with case 2. Unless there's a > way to reset the cache and the app is very careful to do it - but file ca= n > be created by external means and also case 2 would be harder to fix witho= ut > losing the benefits of caching. Yes, it's the problem of detecting & hooking all the ways a file could be created, and then flushing negative entries. And, as you've pointed out, since there's potentially other, non-hookable ways to create files, I'd hav= e to provide API surface to flush entries out of the cache. Thank you for the thoughtful response! --E.