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.

Comments

pounard’s picture

The 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.

R.Muilwijk’s picture

Sounds like a usefull patch! Lets wait before we are sure about the TTL code though.

pounard’s picture

Yes, I agree.

pounard’s picture

It also need deeper testing, I'm playing with a Drupal 7 instance that *seems* to work great, but it need serious testing!

pounard’s picture

Ho, 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?

pounard’s picture

3.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

pounard’s picture

I 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?

Peter Bowey’s picture

Well 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

pounard’s picture

Status: Active » Needs review

Changing to needs review.

Peter Bowey’s picture

APCIterator 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

pounard’s picture

Thank you. I'm awaiting for the module owner to wake up now!

casey’s picture

Dormancy? Patch's looking good!

R.Muilwijk’s picture

Status: Needs review » Needs work
StatusFileSize
new6.48 KB

Moved 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.

R.Muilwijk’s picture

Status: Needs work » Fixed

There was a problem with the isEmpty() regex. Fixed and committed http://drupalcode.org/project/apc.git/commit/a142ff7

pounard’s picture

Nice, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.