1

I found some problem. When i running apc_store and more times update a page (refresh). APC stores previous value and do not stores updated value.

It's following code:

<?php for($i=0;$i<5;$i++) { apc_store('test', $i); echo apc_fetch('test'); } ?>

True output is: 1,2,3,4,5

But sometimes i have: 5,5,5,5,5

Why and how i can correct that bug?

Apc version is last: 3.1.9

user1235098
  • 65
  • 1
  • 6

2 Answers2

3

From the manual: apc_store

Returns TRUE on success or FALSE on failure.

Check it, it could be that it fails to store. Why would apc_store() return false?

Community
  • 1
  • 1
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
0

I guess you are just too fast, thus you'll get the stale value from the previous execution. Remember, that this is a cache and not a kind of persistent global variable. The point is, that you usually save data into a single key only once during a request and you'll try to fetch it in any subsequent request, but not the current one.

It seems you are looking for variables.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173