See http://www.php.net/manual/en/apciterator.gettotalcount.php
You can use the APCIterator class for iterating over set of keys that matches a particular PCRE regex. This is more than useful for dealing with numerous cache entries.
Using this helper will avoid loading the full cache information when dealing with set of keys and will ensure scalability if cache entries number grows. It may also be (a lot?) faster to deal with key deletion.
This patch includes the one about TTL, sorry for that, it was easier because the TTL one also dealt with this loading all keys.
The patch also clean the clear() method that was dealing with $cid being an array, which is not in the original interface signature (therefore useless).
It also simplifies greatly the code (no more FAT!) and makes it more maintainable.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | apc-iterator-1278292.patch | 6.48 KB | R.Muilwijk |
| apc-use-apc-iterator-7.x-1.x.patch | 5.84 KB | pounard |
Comments
Comment #1
pounardThe new protected function signatures I added are also almost the same as new cache API in Drupal core 8.x dev branch, so it brings an easier portage for future (far far future) release for Drupal 8.
Comment #2
R.Muilwijk commentedSounds like a usefull patch! Lets wait before we are sure about the TTL code though.
Comment #3
pounardYes, I agree.
Comment #4
pounardIt also need deeper testing, I'm playing with a Drupal 7 instance that *seems* to work great, but it need serious testing!
Comment #5
pounardHo, and it needs APC >= 3.1.1 I just saw this! Do you think it's risky to assume people have an up to date APC? Maybe the module could deliver two implementations?
Comment #6
pounard3.1.1 was released on 2008-12-12 but it was beta, latest stable with this code 3.1.6 was released on 2010-11-30 see http://pecl.php.net/package/apc
Comment #7
pounardI was thinking about that, this is a major internal API change, a compromise could be to create a new branch for this (may be a 2.x version) that level up the module requirements and keep the legacy 1.x as compat version for outdated boxes.
This module is really small, maintaining the two shouldn't be difficult, what do you think?
Comment #8
Peter Bowey commentedWell done!
The http://drupal.org/files/issues/apc-use-apc-iterator-7.x-1.x.patch
works very well, and was bench-marked by me as faster. [Great idea]
All this tested via Pressflow 6.22 + D6 cache_backport -> http://drupal.org/project/cache_backport
Comment #9
pounardChanging to needs review.
Comment #10
Peter Bowey commentedAPCIterator Review #1
Works very well with latest APC via PECL PHP SVN source:
I happen to think that most people that implement this concept,
will be technically aware enough to build / add the PECL APC -
using the latest archive or SVN. I do not think the over-head of
supporting the older APC versions is essential .... others my differ?
I compiled my version of APC [SVN source] statically into php-fpm
Comment #11
pounardThank you. I'm awaiting for the module owner to wake up now!
Comment #12
casey commentedDormancy? Patch's looking good!
Comment #13
R.Muilwijk commentedMoved developtment for issue http://drupal.org/node/1278268 'Trust APC for TTL and do not proceed to garbage using PHP code' to this patch because it was already in. I've updated the patch to the newest codebase.
I've added the Cache tests for APC. Somehow the Cache saving test and Cache emptiness test don't work anymore after adding this patch.
Comment #14
R.Muilwijk commentedThere was a problem with the isEmpty() regex. Fixed and committed http://drupalcode.org/project/apc.git/commit/a142ff7
Comment #15
pounardNice, thanks!