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

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

Thanks for answer, but what alternative?
The variable is object tree (instances of classes). Objects is updating through ajax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.