php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60720 delete only expired/updated from cache
Submitted: 2012-01-11 19:26 UTC Modified: 2016-11-18 20:55 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:1 of 1 (100.0%)
Same Version:2 (200.0%)
Same OS:2 (200.0%)
From: ck+php dot net at bbshowcase dot org Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ck+php dot net at bbshowcase dot org
New email:
PHP Version: OS:

 

 [2012-01-11 19:26 UTC] ck+php dot net at bbshowcase dot org
Description:
------------
I would love to see an alternate function in the API and button in the APC control panel that clears only expired scripts (those with newer timestamps on disk than in the cache) instead of only using the "clear all" feature.

Essentially this is a "stat once" ability.

This feature exists in eaccelerator and is very useful for those that run with the STAT feature turned off, on active servers with a great deal of scripts.

This way only the one or two scripts that were replaced are cleared out and the rest are left in place for best performance.

I've enclosed code that does this via PHP and the API but the problem is without direct support from native code, open_basedir (and/or safemode) will cause this to fail in many environments because it cannot examine the scripts on disk outside the control panel path and will throw an access error.

This is a similar request that was denied in 2007 under bug #57783 "selectively clear cache" - I am hoping it's a good time to re-examine this need as servers are larger and support more active connections than ever before.

I am specifically asking for native support so files can be examined outside of open_basedir restrictions.

Test script:
---------------
$data = apc_cache_info(); 
if (empty($data['cache_list'])) { die('no cached files?');}
$expired=array();
foreach ($data['cache_list'] as $file) {
	if (!empty($file['mtime']) && !empty($file['filename']) 
		&& (!file_exists($file['filename']) || (int)$file['mtime']<filemtime($file['filename']))) {
			$expired[]=$file['filename'];
	}
}
if (!empty($expired)) {apc_delete_file($expired);} 
echo count($expired),' removed from cache';


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-22 19:52 UTC] rasmus@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: gopalv
 [2016-11-18 20:55 UTC] kalle@php.net
-Status: Assigned +Status: Wont fix -Assigned To: gopalv +Assigned To:
 [2016-11-18 20:55 UTC] kalle@php.net
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC