|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-12-17 17:50 UTC] marc dot bennewitz at giata dot de
Description:
------------
apc_exist:
There is no function to only check if an key is available within the cache. To test the existence I have to use apc_fetch('key', $success) and check the $seccess variable but it isn't as high-performance as apc_exist because it haven't to return cached data.
apc_info:
to get more information about only one cached key I have to instantiate a new APCIterator with a search string for the key like this:
$it = new APCIterator('user', '/^'.preg_quote($key).'$/', APC_ITER_ALL, 1, APC_LIST_ACTIVE);
if ($it->valid()) {
$info = $it->current();
echo $info['mtime'];
}
but thats not the high-performance to get additional information about only one cached key. It is better to use something like this:
$info = apc_info($key, APC_ITER_ALL);
if ($info !== false) {
echo $info['mtime'];
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
My only argument against the apc_exists() functionality would be that it could add more kludge to the API, but if there's a need for it it's simple enough to add. Any objections by any1 else? APCIterator will also accept an array of keys to find (rather than a regex). ie: $it = new APCIterator('user', array($key), APC_ITER_ALL, 1, APC_LIST_ACTIVE); Does this solve your apc_info use case?Thanks for the quick implementation. - With a single key it seems to work fine :) - With an array of keys it returns false ever :( - With APCIterator a fatal error is occured Is it hard to implement APCIterator as argument like apc_delete, too ? Test Script: apc_store('id1', 'data1'); apc_store('id2', 'data2'); var_dump( apc_exists('id1') ); var_dump( apc_exists('id2') ); var_dump( apc_exists(array('id1', 'id2')) ); var_dump( apc_exists(new APCIterator('/^id[12]$/', APC_ITER_NONE, 1, APC_LIST_ACTIVE)) ); Output: bool(true) bool(true) bool(false) PHP Catchable fatal error: Object of class APCIterator could not be converted to string ...Ops sorry here is a fix of my last test script (The result is the same): - var_dump( apc_exists(new APCIterator('/^id[12]$/', APC_ITER_NONE, 1, APC_LIST_ACTIVE)) ); + var_dump( apc_exists(new APCIterator('user', '/^id[12]$/', APC_ITER_NONE, 1, APC_LIST_ACTIVE)) );apc_exists('foo'), this type of command is not working me. It says: Fatal error: Call to undefined function apc_exists() in ****** on line 46