9

Is there a way to fetch and print, all the data stored in apc's storage?

I need to do so for testing and debugging purposes.

I know I can retrieve a specific data by doing apc_fetch(id), but I don't know any way to retrieve all the data by passing (as an example) a *

Alex
  • 7,538
  • 23
  • 84
  • 152

4 Answers4

13

Yes, you can get this with APCIterator. This allows you to loop through all the items stored with APC.

$iter = new APCIterator('user');
foreach ($iter as $item) {
    echo $item['key'] . ': ' . $item['value'];
}
lonesomeday
  • 233,373
  • 50
  • 316
  • 318
  • Yes sir, with this code I get the keys... which is more than enough to see what I'm caching in my app – Alex May 29 '12 at 13:19
  • When doing this i get " Allowed memory size of 134217728 bytes exhausted" also backtrace shows that the rewind() method is to blame. My regex matches exactly 1 entry in APC. Any idea how to fix this? – user2021201 Mar 25 '16 at 16:45
2

apc_cache_info() might be what you're looking for

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • ok, this isn't exactly what I am looking for. This doesn't retrieve the cached data. But thanks any way – Alex May 29 '12 at 13:13
1

The APCIterator class might be what you are looking for.

Samy Dindane
  • 17,900
  • 3
  • 40
  • 50
-2

APC extension is not installed on your APache.

so download a APc based on your PHP version and install it.

http://downloads.php.net/pierre/

if you need installation tuts. read it here.

http://kvcodes.com/2014/06/solution-call-undefined-function-apc_fetch/

varadha
  • 59
  • 2