是否可以使用通配符清除apcu缓存?
例如,我可能有一堆缓存密钥:
products_fooandbars product_1_foo
users_fooandbars user_1_foo user_1_bar
user_2_foo user_2_bar
是否有一种方法可以清除用户1所拥有的与此user_1_*类似的所有内容,还是清除所有用户的类似于此user_*的
我在理论apc缓存类中使用Symfony
发布于 2016-10-26 18:16:53
OP指的是http://php.net/manual/en/book.apcu.php,而不是APC。
在函数名称等方面没有太大的差别,但最好让任何人都清楚,APC是旧版本,APCu是新版本,具有更好的实现。
旧的APC实现了操作码缓存和用户对象缓存。APCu只实现用户对象缓存。对于操作码缓存,您可以使用其他东西,如Zend OPcache。尽管如此,以下是@Evgenly‘s的最新版本:
// delete all keys beginning with a regex match
foreach(new APCUIterator('/^MY_KEY/') as $apcu_cache){
echo 'key: ' . $apcu_cache['key'] . PHP_EOL;
echo 'val: ' . $apcu_cache['value'];
apcu_delete($apcu_cache['key']);
}前面是说明性的,您也可以这样做:
apcu_delete(new APCUIterator('/^MY_KEY/'));发布于 2015-05-18 21:21:08
我相信你应该试一试,因为它被描述为http://php.net/manual/en/function.apc-delete.php#101794
// delete all keys beginning with a regex match on MY_APC_TESTA
$toDelete = new APCIterator('user', '/^MY_KEY/', APC_ITER_VALUE);
var_dump( apc_delete($toDelete) ); https://stackoverflow.com/questions/30312532
复制相似问题